You are previewing Penetration Testing with Perl.
O'Reilly logo
Penetration Testing with Perl

Book Description

Harness the power of Perl to perform professional penetration testing

In Detail

This guide will teach you the fundamentals of penetration testing with Perl, providing an understanding of the mindset of a hacker. In the first few chapters, you will study how to utilize Perl with Linux and the regular expression syntax. After that, you will learn how to use Perl for WAN target analysis, and Internet and external footprinting. You will learn to use Perl for automated web application and site penetration testing. We also cover intelligence gathering techniques from data obtained from footprinting and simple file forensics with file metadata.

By the end of this book, you will bring all of your code together into a simple graphical user interface penetration testing framework. Through this guide, you will have acquired the knowledge to apply Perl programming to any penetration testing phase and learn the importance of applying our technique in the methodology and context of the Penetration Testing Execution Standard.

What You Will Learn

  • Develop your knowledge on the methodology, legality, and ethics involved in penetration testing
  • Utilize Linux OS, shell, and networking utilities using Perl
  • Manipulate and capture LAN network traffic in modern switched environments
  • Apply Perl to the Aircrack-ng suite
  • Combine external, internal, and Internet footprinting, and open source intelligence gathering
  • Perform web penetration testing and automation, including Local and Remote File Inclusion, SQL injection, cross-site scripting, and CMS vulnerability analysis
  • Stabilize your tests by using patterns such as Action Wrapper and Black Hole Proxy
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

    Table of Contents

    1. Penetration Testing with Perl
      1. Table of Contents
      2. Penetration Testing with Perl
      3. Credits
      4. About the Author
      5. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. 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
      8. 1. Perl Programming
        1. Files
        2. Regular expressions
          1. Literals versus metacharacters
          2. Quantifiers
          3. Anchors
          4. Character classes
            1. Ranged character classes
          5. Grouping text (strings)
          6. Backreferences
        3. Perl string functions and operators
          1. The Perl m// matching operator
          2. The Perl s/// substitution operator
          3. Regular expressions and the split() function
          4. Regular expressions and the grep() function
        4. CPAN Perl modules
        5. CPAN minus
        6. Summary
      9. 2. Linux Terminal Output
        1. Built-in bash commands
          1. Variable expansion, grouping, and arguments
          2. Script execution from bash
        2. Input/output streams
          1. Output to files
            1. Input redirection
            2. Output to an input stream
            3. Error handling with the shell
          2. Basic bash programming
            1. Forking processes in the shell
        3. Killing runaway forked processes
          1. Bash command execution from Perl
        4. Summary
      10. 3. IEEE 802.3 Wired Network Mapping with Perl
        1. Footprinting
        2. Internet footprinting
        3. Common tools for scanning
          1. Address Resolution Protocol scanning tools
          2. Server Message Block information tools
          3. Internet Control Message Protocol versus Transmission Control Protocol versus ARP discovery
        4. Designing our own live host scanner
          1. Designing our own port scanner
          2. Writing an SMB scanner
          3. Banner grabbing
          4. A brute force application
        5. Summary
      11. 4. IEEE 802.3 Wired Network Manipulation with Perl
        1. Packet capturing
          1. Packet capture filtering
          2. Packet layers
            1. The application layer
        2. MitM
          1. ARP spoofing with Perl
        3. Enabling packet forwarding
        4. Network remapping with packet capture
        5. Summary
      12. 5. IEEE 802.11 Wireless Protocol and Perl
        1. 802.11 terminologies and packet analysis
          1. Management frames
          2. Control and data frames
        2. Linux wireless utilities
          1. RFMON versus probing
        3. 802.11 packet capturing with Perl
          1. 802.11 frame headers
        4. Writing an 802.11 protocol analyzer in Perl
        5. Perl and Aircrack-ng
        6. Summary
      13. 6. Open Source Intelligence
        1. What's covered
        2. Google dorks
        3. E-mail address gathering
          1. Using Google for e-mail address gathering
          2. Using social media for e-mail address gathering
            1. Google+
            2. LinkedIn
            3. Facebook
        4. Domain Name Services
          1. The Whois query
          2. The DIG query
          3. Brute force enumeration
          4. Zone transfers
          5. Traceroute
          6. Shodan
        5. More intelligence
        6. Summary
      14. 7. SQL Injection with Perl
        1. Web service discovery
          1. Service discovery
          2. File discovery
        2. SQL injection
          1. GET requests
            1. Integer SQL injection
            2. String SQL injection
          2. SQL column counting
        3. MySQL post exploitation
          1. Discovering the column count
          2. Gathering server information
          3. Obtaining table result sets
          4. Obtaining records
        4. Data-driven blind SQL injection
        5. Time-based blind SQL injection
        6. Summary
      15. 8. Other Web-based Attacks
        1. Cross-site scripting
          1. The reflected XSS
          2. URL encoding
          3. Enhancing the XSS attack
            1. XSS caveats and hints
        2. File inclusion vulnerability discovery
          1. Local File Inclusion
            1. Logfile code injection
          2. Remote File Inclusion
        3. Content management systems
        4. Summary
      16. 9. Password Cracking
        1. Digital credential analysis
        2. Cracking SHA1 and MD5
          1. SHA1 cracking with Perl
            1. Parallel processing in Perl
          2. MD5 cracking with Perl
          3. Using online resources for password cracking
          4. Salted hashes
            1. Linux passwords
        3. WPA2 passphrase cracking with Perl
          1. Four-way Handshake
            1. 802.11 EAPOL Message 1
            2. 802.11 EAPOL Message 2
          2. The Perl WPA2 cracking program
        4. Cracking ZIP file passwords
        5. Summary
      17. 10. Metadata Forensics
        1. Metadata and Exif
        2. Metadata extractor
          1. Extracting metadata from images
          2. Extracting metadata from PDF files
        3. Summary
      18. 11. Social Engineering with Perl
        1. Psychology
        2. Perl Linux/Unix viruses
          1. Optimization for trust
          2. Virus replication
        3. Spear phishing
          1. Spoofing e-mails with Perl
            1. Setting up Exim4
            2. Using the Mail::Sendmail Perl module
        4. Summary
      19. 12. Reporting
        1. Who is this for?
          1. Executive Report
          2. Technical Report
        2. Documenting with Perl
          1. STDOUT piping
          2. CSV versus TXT
          3. Graphing with Perl
          4. Creating a PDF file
        3. Logging data to MySQL
        4. HTML reporting
        5. Summary
      20. 13. Perl/Tk
        1. Event-driven programming
        2. Explaining the Perl/Tk widgets
        3. Widgets and the grid
        4. The GUI host discovery tool
        5. A tabbed GUI environment
        6. Summary
      21. Index