You are previewing Nmap 6: Network Exploration and Security Auditing Cookbook.
O'Reilly logo
Nmap 6: Network Exploration and Security Auditing Cookbook

Book Description

Want to master Nmap and its scripting engine? Then this book is for you – packed with practical tasks and precise instructions, it’s a comprehensive guide to penetration testing and network monitoring. Security in depth.

  • Master the power of Nmap 6

  • Learn how the Nmap Scripting Engine works and develop your own scripts!

  • 100% practical tasks, relevant and explained step-by-step with exact commands and optional arguments description

  • In Detail

    Nmap is a well known security tool used by penetration testers and system administrators. The Nmap Scripting Engine (NSE) has added the possibility to perform additional tasks using the collected host information. Tasks like advanced fingerprinting and service discovery, information gathering, and detection of security vulnerabilities.

    "Nmap 6: Network exploration and security auditing cookbook" will help you master Nmap and its scripting engine. You will learn how to use this tool to do a wide variety of practical tasks for pentesting and network monitoring. Finally, after harvesting the power of NSE, you will also learn how to write your own NSE scripts.

    "Nmap 6: Network exploration and security auditing cookbook" is a book full of practical knowledge for every security consultant, administrator or enthusiast looking to master Nmap. The book overviews the most important port scanning and host discovery techniques supported by Nmap. You will learn how to detect mis-configurations in web, mail and database servers and also how to implement your own monitoring system.

    The book also covers tasks for reporting, scanning numerous hosts, vulnerability detection and exploitation, and its strongest aspect; information gathering.

    Table of Contents

    1. Nmap 6: Network Exploration and Security Auditing Cookbook
      1. Table of Contents
      2. Nmap 6: Network Exploration and Security Auditing Cookbook
      3. Credits
      4. About the Author
      5. Acknowledgement
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      9. 1. Nmap Fundamentals
        1. Introduction
        2. Downloading Nmap from the official source code repository
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Experimenting with development branches
            2. Keeping your source code up-to-date
          5. See also
        3. Compiling Nmap from source code
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. OpenSSL development libraries
            2. Configure directives
            3. Precompiled packages
            4. See also
        4. Listing open ports on a remote host
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Privileged versus unprivileged
            2. Port states
            3. Port scanning techniques supported by Nmap
          4. See also
        5. Fingerprinting services of a remote host
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Aggressive detection
            2. Submitting service fingerprints
          4. See also
        6. Finding live hosts in your network
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Traceroute
            2. NSE scripts
          4. See also
        7. Scanning using specific port ranges
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Running NSE scripts
          1. How to do it...
          2. How it works...
          3. There's more...
            1. NSE script arguments
            2. Adding new scripts
            3. NSE script categories
          4. See also
        9. Scanning using a specified network interface
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Checking a TCP connection
          4. See also
        10. Comparing scan results with Ndiff
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Output format
            2. Verbose mode
          5. See also
        11. Managing multiple scanning profiles with Zenmap
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Editing and deleting a scan profile
          4. See also
        12. Detecting NAT with Nping
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Nping Echo Protocol
          4. See also
        13. Monitoring servers remotely with Nmap and Ndiff
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Monitoring specific services
          4. See also
      10. 2. Network Exploration
        1. Introduction
        2. Discovering hosts with TCP SYN ping scans
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Privileged versus unprivileged TCP SYN ping scan
            2. Firewalls and traffic filters
          4. See also
        3. Discovering hosts with TCP ACK ping scans
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Privileged versus unprivileged TCP ACK ping scan
            2. Selecting ports in TCP ACK ping scans
          4. See also
        4. Discovering hosts with UDP ping scans
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Selecting ports in UDP ping scans
          4. See also
        5. Discovering hosts with ICMP ping scans
          1. How to do it...
          2. How it works...
          3. There's more...
            1. ICMP types
          4. See also
        6. Discovering hosts with IP protocol ping scans
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Supported IP protocols and their payloads
          4. See also
        7. Discovering hosts with ARP ping scans
          1. How to do it...
          2. How it works...
          3. There's more...
            1. MAC address spoofing
          4. See also
        8. Discovering hosts using broadcast pings
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Target library
          4. See also
        9. Hiding our traffic with additional random data
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Forcing DNS resolution
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Specifying different DNS nameservers
          4. See also
        11. Excluding hosts from your scans
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Excluding a host list from your scans
          4. See also
        12. Scanning IPv6 addresses
          1. How to do it...
          2. How it works...
          3. There's more...
            1. OS detection in IPv6 scanning
          4. See also
        13. Gathering network information with broadcast scripts
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Target library
          4. See also
      11. 3. Gathering Additional Host Information
        1. Introduction
        2. Geolocating an IP address
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Submitting a new geo-location provider
          5. See also
        3. Getting information from WHOIS records
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Disabling cache and the implications of this
          4. See also
        4. Checking if a host is known for malicious activities
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Collecting valid e-mail accounts
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. NSE script arguments
            2. HTTP User Agent
          5. See also
        6. Discovering hostnames pointing to the same IP address
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Brute forcing DNS records
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Target library
          4. See also
        8. Fingerprinting the operating system of a host
          1. How to do it...
          2. How it works...
          3. There's more...
            1. OS detection in verbose mode
            2. Submitting new OS fingerprints
          4. See also
        9. Discovering UDP services
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Port selection
          4. See also
        10. Listing protocols supported by a remote host
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Customizing the IP protocol scan
          4. See also
        11. Discovering stateful firewalls by using a TCP ACK scan
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Port states
          4. See also
        12. Matching services with known security vulnerabilities
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        13. Spoofing the origin IP of a port scan
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. The IP ID sequence number
          5. See also
      12. 4. Auditing Web Servers
        1. Introduction
        2. Listing supported HTTP methods
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Interesting HTTP methods
            2. HTTP User Agent
            3. HTTP pipelining
          4. See also
        3. Checking if an HTTP proxy is open
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
          4. See also
        4. Discovering interesting files and directories on various web servers
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
            2. HTTP pipelining
          4. See also
        5. Brute forcing HTTP authentication
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
            2. HTTP pipelining
            3. Brute modes
          4. See also
        6. Abusing mod_userdir to enumerate user accounts
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
            2. HTTP pipelining
          4. See also
        7. Testing default credentials in web applications
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
          4. See also
        8. Brute-force password auditing WordPress installations
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
            2. Brute modes
          4. See also
        9. Brute-force password auditing Joomla! installations
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
            2. Brute modes
          4. See also
        10. Detecting web application firewalls
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
            2. HTTP pipelining
          4. See also
        11. Detecting possible XST vulnerabilities
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
          4. See also
        12. Detecting Cross Site Scripting vulnerabilities in web applications
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
            2. HTTP pipelining
          4. See also
        13. Finding SQL injection vulnerabilities in web applications
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
            2. HTTP pipelining
          4. See also
        14. Detecting web servers vulnerable to slowloris denial of service attacks
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
          4. See also
      13. 5. Auditing Databases
        1. Introduction
        2. Listing MySQL databases
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Listing MySQL users
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Listing MySQL variables
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Finding root accounts with empty passwords in MySQL servers
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Brute forcing MySQL passwords
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Brute modes
          4. See also
        7. Detecting insecure configurations in MySQL servers
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Brute forcing Oracle passwords
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Brute modes
          4. See also
        9. Brute forcing Oracle SID names
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Retrieving MS SQL server information
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Force scanned ports only in NSE scripts for MS SQL
          4. See also
        11. Brute forcing MS SQL passwords
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Brute modes
          4. See also
        12. Dumping the password hashes of an MS SQL server
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        13. Running commands through the command shell on MS SQL servers
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        14. Finding sysadmin accounts with empty passwords on MS SQL servers
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Force scanned ports only in NSE scripts for MS SQL
          4. See also
        15. Listing MongoDB databases
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        16. Retrieving MongoDB server information
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        17. Listing CouchDB databases
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        18. Retrieving CouchDB database statistics
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      14. 6. Auditing Mail Servers
        1. Introduction
        2. Discovering valid e-mail accounts using Google Search
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Debugging NSE scripts
          5. See also
        3. Detecting open relays
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging NSE scripts
          4. See also
        4. Brute forcing SMTP passwords
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Brute modes
            2. Debugging NSE scripts
          4. See also
        5. Enumerating users in an SMTP server
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging NSE scripts
          4. See also
        6. Detecting backdoor SMTP servers
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Brute forcing IMAP passwords
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Brute modes
            2. Debugging NSE scripts
          4. See also
        8. Retrieving the capabilities of an IMAP mail server
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging NSE scripts
          4. See also
        9. Brute forcing POP3 passwords
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging NSE scripts
          4. See also
        10. Retrieving the capabilities of a POP3 mail server
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging NSE scripts
          4. See also
        11. Detecting vulnerable Exim SMTP servers version 4.70 through 4.75
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging NSE scripts
          4. See also
      15. 7. Scanning Large Networks
        1. Introduction
        2. Scanning an IP address range
          1. How to do it...
          2. How it works...
          3. There's more...
            1. CIDR notation
            2. Privileged versus unprivileged
            3. Port states
            4. Port scanning techniques
          4. See also
        3. Reading targets from a text file
          1. How to do it...
          2. How it works...
          3. There's more...
            1. CIDR notation
            2. Excluding a host list from your scans
          4. See also
        4. Scanning random targets
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Legal issues with port scanning
            2. Target library
          4. See also
        5. Skipping tests to speed up long scans
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Scanning phases of Nmap
            2. Debugging Nmap scans
            3. Aggressive detection
          4. See also
        6. Selecting the correct timing template
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Adjusting timing parameters
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Scanning phases of Nmap
            2. Debugging Nmap scans
          4. See also
        8. Adjusting performance parameters
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Scanning phases of Nmap
            2. Debugging Nmap scans
          4. See also
        9. Collecting signatures of web servers
          1. How to do it...
          2. How it works...
          3. There's more...
            1. HTTP User Agent
          4. See also
        10. Distributing a scan among several clients using Dnmap
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Dnmap statistics
          5. See also
      16. 8. Generating Scan Reports
        1. Introduction
        2. Saving scan results in normal format
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Saving Nmap's output in all formats
            2. Including debugging information in output logs
            3. Including the reason for a port or host state
            4. Appending Nmap output logs
            5. OS detection in verbose mode
          4. See also
        3. Saving scan results in an XML format
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Saving Nmap's output in all formats
            2. Appending Nmap output logs
            3. Structured script output for NSE
          4. See also
        4. Saving scan results to a SQLite database
          1. Getting Ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Dumping the database in CSV format
            2. Fixing outputpbnj
          5. See also
        5. Saving scan results in a grepable format
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Saving Nmap's output in all formats
            2. Appending Nmap output logs
          4. See also
        6. Generating a network topology graph with Zenmap
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Generating an HTML scan report
          1. Getting Ready...
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Reporting vulnerability checks performed during a scan
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      17. 9. Writing Your Own NSE Scripts
        1. Introduction
        2. Making HTTP requests to identify vulnerable Trendnet webcams
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging Nmap scripts
            2. Setting the user agent pragmatically
            3. HTTP pipelining
          4. See also
        3. Sending UDP payloads by using NSE sockets
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Exception handling
            2. Debugging Nmap scripts
          4. See also
        4. Exploiting a path traversal vulnerability with NSE
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging NSE scripts
            2. Setting the user agent pragmatically
            3. HTTP pipelining
          4. See also
        5. Writing a brute force script
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging NSE scripts
            2. Exception handling
            3. Brute modes
          4. See also
        6. Working with the web crawling library
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging NSE scripts
            2. Setting the user agent pragmatically
            3. HTTP pipelining
            4. Exception handling
          4. See also
        7. Reporting vulnerabilities correctly in NSE scripts
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Vulnerability states of the library vulns
          4. See also
        8. Writing your own NSE library
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging NSE scripts
            2. Exception handling
            3. Importing modules in C
          4. See also
        9. Working with NSE threads, condition variables, and mutexes in NSE
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Debugging NSE scripts
            2. Exception handling
          4. See also
      18. A. References
      19. Index