Cover image for Security Warrior

Book description

When it comes to network security, many users and administrators are running scared, and justifiably so. The sophistication of attacks against computer systems increases with each new Internet worm. What's the worst an attacker can do to you? You'd better find out, right? That's what Security Warrior teaches you. Based on the principle that the only way to defend yourself is to understand your attacker in depth, Security Warrior reveals how your systems can be attacked. Covering everything from reverse engineering to SQL attacks, and including topics like social engineering, antiforensics, and common attacks against UNIX and Windows systems, this book teaches you to know your enemy and how to be prepared to do battle. Security Warrior places particular emphasis on reverse engineering. RE is a fundamental skill for the administrator, who must be aware of all kinds of malware that can be installed on his machines -- trojaned binaries, "spyware" that looks innocuous but that sends private data back to its creator, and more. This is the only book to discuss reverse engineering for Linux or Windows CE. It's also the only book that shows you how SQL injection works, enabling you to inspect your database and web applications for vulnerability. Security Warrior is the most comprehensive and up-to-date book covering the art of computer war: attacks against computer systems and their defenses. It's often scary, and never comforting. If you're on the front lines, defending your site against attackers, you need this book. On your shelf--and in your hands.

Table of Contents

  1. Security Warrior
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Preface
      1. Organization of This Book
      2. Part I: Software Cracking
      3. Part II: Network Stalking
      4. Part III: Platform Attacks
      5. Part IV: Advanced Defense
      6. Part V: Appendix
      7. Conventions Used in This Book
      8. Using Code Examples
      9. Comments and Questions
      10. Acknowledgments
    4. I. Software Cracking
      1. 1. Assembly Language
        1. 1.1. Registers
          1. 1.1.1. Understanding the Stack
          2. 1.1.2. Addressing
        2. 1.2. ASM Opcodes
        3. 1.3. References
      2. 2. Windows Reverse Engineering
        1. 2.1. History of RCE
        2. 2.2. Reversing Tools
          1. 2.2.1. Hex Editors
          2. 2.2.2. Disassemblers
          3. 2.2.3. Debuggers
          4. 2.2.4. System Monitors
          5. 2.2.5. Unpackers
            1. 2.2.5.1. The PE file format
            2. 2.2.5.2. ProcDump
          6. 2.2.6. Personal Firewalls
          7. 2.2.7. Install Managers
        3. 2.3. Reverse Engineering Examples
          1. 2.3.1. Example 1: A Sample Crackme
          2. 2.3.2. Example 2: Reversing Malicious Code
        4. 2.4. References
      3. 3. Linux Reverse Engineering
        1. 3.1. Basic Tools and Techniques
          1. 3.1.1. Overview of the Target
          2. 3.1.2. Debugging
          3. 3.1.3. Runtime Monitoring
          4. 3.1.4. Disassembly
          5. 3.1.5. Hex Dumps
        2. 3.2. A Good Disassembly
          1. 3.2.1. Identifying Functions
          2. 3.2.2. Intermediate Code Generation
          3. 3.2.3. Program Control Flow
        3. 3.3. Problem Areas
          1. 3.3.1. Antidebugging
          2. 3.3.2. Antidisassembly
        4. 3.4. Writing New Tools
          1. 3.4.1. The ELF File Format
            1. 3.4.1.1. Sample ELF reader
          2. 3.4.2. Debugging with ptrace
          3. 3.4.3. The GNU BFD Library
          4. 3.4.4. Disassembling with libopcodes
        5. 3.5. References
      4. 4. Windows CE Reverse Engineering
        1. 4.1. Windows CE Architecture
          1. 4.1.1. Processors
          2. 4.1.2. Kernel, Processes, and Threads
          3. 4.1.3. Memory Architecture
          4. 4.1.4. Graphics, Windowing, and Event Subsystem (GWES)
        2. 4.2. CE Reverse Engineering Fundamentals
          1. 4.2.1. The ARM Processor
          2. 4.2.2. ARM Opcodes
            1. 4.2.2.1. Branch (B)
            2. 4.2.2.2. Branch with Link (BL)
            3. 4.2.2.3. Move (MOV)
            4. 4.2.2.4. Compare (CMP)
            5. 4.2.2.5. Load/Store (LDR/STR)
            6. 4.2.2.6. Shifting
        3. 4.3. Practical CE Reverse Engineering
          1. 4.3.1. Hello, World!
          2. 4.3.2. CE Cracking Techniques
            1. 4.3.2.1. Predictable system calls
            2. 4.3.2.2. strlen and wcslen
            3. 4.3.2.3. strcmp and CMP
            4. 4.3.2.4. NOP sliding
          3. 4.3.3. Disassembling a CE Program
            1. 4.3.3.1. Loading the file
          4. 4.3.4. Microsoft's eMbedded Visual Tools
          5. 4.3.5. Using the MVT
          6. 4.3.6. Experiencing the MVC Environment
          7. 4.3.7. Reverse Engineering test.exe
        4. 4.4. Reverse Engineering serial.exe
          1. 4.4.1. Overview
            1. 4.4.1.1. Loading the target
            2. 4.4.1.2. Debugging serial.exe
          2. 4.4.2. Step-Through Investigation
          3. 4.4.3. Abusing the System
          4. 4.4.4. The Cracks
            1. 4.4.4.1. Crack 1: Sleight of hand
            2. 4.4.4.2. Crack 2: The NOP slide
            3. 4.4.4.3. Crack 3: Preventive maintenance
        5. 4.5. References
      5. 5. Overflow Attacks
        1. 5.1. Buffer Overflows
          1. 5.1.1. A Sample Overflow
        2. 5.2. Understanding Buffers
        3. 5.3. Smashing the Stack
        4. 5.4. Heap Overflows
        5. 5.5. Preventing Buffer Overflows
          1. 5.5.1. Automated Source-Code Checking
          2. 5.5.2. Compiler Add-Ons
          3. 5.5.3. Miscellaneous Protection Methods
        6. 5.6. A Live Challenge
        7. 5.7. References
    5. II. Network Stalking
      1. 6. TCP/IP Analysis
        1. 6.1. A Brief History of TCP/IP
        2. 6.2. Encapsulation
        3. 6.3. TCP
          1. 6.3.1. TCP Features
          2. 6.3.2. TCP Packet Field Descriptions
        4. 6.4. IP
          1. 6.4.1. IP Packet Format
        5. 6.5. UDP
        6. 6.6. ICMP
        7. 6.7. ARP
        8. 6.8. RARP
        9. 6.9. BOOTP
        10. 6.10. DHCP
        11. 6.11. TCP/IP Handshaking
        12. 6.12. Covert Channels
        13. 6.13. IPv6
          1. 6.13.1. Features of IPv6
          2. 6.13.2. IPv6 Addressing
          3. 6.13.3. Security Aspects of IPv6
        14. 6.14. Ethereal
        15. 6.15. Packet Analysis
        16. 6.16. Fragmentation
          1. 6.16.1. Fragmentation Variables
          2. 6.16.2. Exploiting Fragments
          3. 6.16.3. Fragmenting with Nmap
          4. 6.16.4. hping
          5. 6.16.5. Fragroute
        17. 6.17. References
      2. 7. Social Engineering
        1. 7.1. Background
          1. 7.1.1. Less Elite, More Effective
          2. 7.1.2. Common Misconceptions
        2. 7.2. Performing the Attacks
          1. 7.2.1. Active and Passive Attacks
            1. 7.2.1.1. Sample 1: Impersonation
            2. 7.2.1.2. Sample 2: Impersonation and authority
            3. 7.2.1.3. Sample 3: Blackmail
            4. 7.2.1.4. Sample 4: Sympathy
          2. 7.2.2. Preparing for an Attack
          3. 7.2.3. Social Engineering Action Plan
          4. 7.2.4. Social Engineering Information Collection Template
        3. 7.3. Advanced Social Engineering
        4. 7.4. References
      3. 8. Reconnaissance
        1. 8.1. Online Reconnaissance
          1. 8.1.1. Passive Reconnaissance
            1. 8.1.1.1. Utilities
            2. 8.1.1.2. Web reconnaissance
          2. 8.1.2. Active Reconnaissance
            1. 8.1.2.1. Email
            2. 8.1.2.2. Web site analysis
            3. 8.1.2.3. FTP
            4. 8.1.2.4. A word on stealth
            5. 8.1.2.5. Human reconnaissance
        2. 8.2. Conclusion
        3. 8.3. References
      4. 9. OS Fingerprinting
        1. 9.1. Telnet Session Negotiation
        2. 9.2. TCP Stack Fingerprinting
          1. 9.2.1. Nmap Test
          2. 9.2.2. Nmap Techniques
          3. 9.2.3. Defeating Nmap
        3. 9.3. Special-Purpose Tools
        4. 9.4. Passive Fingerprinting
        5. 9.5. Fuzzy Operating System Fingerprinting
          1. 9.5.1. Obstacles to Fingerprinting
          2. 9.5.2. Fuzzy Solution to Operating System Fingerprinting
        6. 9.6. TCP/IP Timeout Detection
        7. 9.7. References
      5. 10. Hiding the Tracks
        1. 10.1. From Whom Are You Hiding?
        2. 10.2. Postattack Cleanup
          1. 10.2.1. System Logs
            1. 10.2.1.1. The exploit attempt itself
            2. 10.2.1.2. The attacker's accesses before the exploit
            3. 10.2.1.3. Erasing logfiles
          2. 10.2.2. Application Logs
          3. 10.2.3. Unix Shell History
          4. 10.2.4. Unix Binary Logs
          5. 10.2.5. Other Records
        3. 10.3. Forensic Tracks
          1. 10.3.1. File Traces
          2. 10.3.2. Timestamps
            1. 10.3.2.1. Countermeasures
        4. 10.4. Maintaining Covert Access
          1. 10.4.1. Hiding
          2. 10.4.2. Hidden Access
        5. 10.5. References
    6. III. Platform Attacks
      1. 11. Unix Defense
        1. 11.1. Unix Passwords
        2. 11.2. File Permissions
          1. 11.2.1. Attributes and Capabilities
        3. 11.3. System Logging
        4. 11.4. Network Access in Unix
          1. 11.4.1. TCP Wrappers
          2. 11.4.2. NFS/NIS
          3. 11.4.3. Backups
          4. 11.4.4. X Window System
        5. 11.5. Unix Hardening
          1. 11.5.1. Hardening Areas
            1. 11.5.1.1. Checking installed software
            2. 11.5.1.2. Patching the system
            3. 11.5.1.3. Filesystem permissions
            4. 11.5.1.4. Login security
            5. 11.5.1.5. User security
            6. 11.5.1.6. Physical security
            7. 11.5.1.7. Network security
            8. 11.5.1.8. Daemon security
            9. 11.5.1.9. System logging and accounting
          2. 11.5.2. Automated Hardening via Scripts
            1. 11.5.2.1. Linux Bastille
            2. 11.5.2.2. Kernel-level hardening
            3. 11.5.2.3. Pitbull
            4. 11.5.2.4. Openwall kernel patch
            5. 11.5.2.5. LIDS
            6. 11.5.2.6. "Secure Unix"
            7. 11.5.2.7. Encrypted filesystems
        6. 11.6. Unix Network Defense
          1. 11.6.1. Advanced TCP Wrappers
            1. 11.6.1.1. tcpd
            2. 11.6.1.2. libwrap
          2. 11.6.2. Application-Specific Access Controls
            1. 11.6.2.1. BIND (DNS daemon)
            2. 11.6.2.2. sendmail (some versions)
            3. 11.6.2.3. SSH daemon (sshd)
            4. 11.6.2.4. Apache web server
          3. 11.6.3. System Configuration Changes
            1. 11.6.3.1. Security from eavesdropping
            2. 11.6.3.2. Secure Shell
          4. 11.6.4. Host-Based Firewalls
            1. 11.6.4.1. Linux iptables and ipchains
        7. 11.7. References
      2. 12. Unix Attacks
        1. 12.1. Local Attacks
          1. 12.1.1. Physical Abuses
          2. 12.1.2. Boot Prompt Attacks
          3. 12.1.3. Boot Interrupt
          4. 12.1.4. Screensaver Attacks
          5. 12.1.5. Path Abuse
          6. 12.1.6. Password Attacks
          7. 12.1.7. SUID Abuse
          8. 12.1.8. /tmp and Symlink/Hardlink Abuse
          9. 12.1.9. Breaking Out of chroot Jail
        2. 12.2. Remote Attacks
          1. 12.2.1. TCP
          2. 12.2.2. UDP
          3. 12.2.3. Top Unix Vulnerabilities
        3. 12.3. Unix Denial-of-Service Attacks
          1. 12.3.1. Local Attacks
            1. 12.3.1.1. Destruction of resources
            2. 12.3.1.2. Resource exhaustion
            3. 12.3.1.3. Filling kernel data structures
          2. 12.3.2. Network Attacks
          3. 12.3.3. Distributed Denial-of-Service Attacks
            1. 12.3.3.1. Coordinated and reflexive denial-of-service attacks
            2. 12.3.3.2. Application-level denial-of-service attacks
        4. 12.4. References
      3. 13. Windows Client Attacks
        1. 13.1. Denial-of-Service Attacks
          1. 13.1.1. SMB Attack
          2. 13.1.2. Universal Plug and Play Attack
          3. 13.1.3. Help Center Attack
        2. 13.2. Remote Attacks
        3. 13.3. Remote Desktop/Remote Assistance
          1. 13.3.1. Abusing the Remote Desktop
            1. 13.3.1.1. tscrack
          2. 13.3.2. Abusing Remote Assistance
        4. 13.4. References
      4. 14. Windows Server Attacks
        1. 14.1. Release History
        2. 14.2. Kerberos Authentication Attacks
        3. 14.3. Kerberos Authentication Review
          1. 14.3.1. Accessing Cross-Domain Network Resources
          2. 14.3.2. Weaknesses in the Kerberos Protocol
            1. 14.3.2.1. Vulnerability
            2. 14.3.2.2. Obtaining the password-verification material
            3. 14.3.2.3. Decrypting the timestamp
        4. 14.4. Defeating Buffer Overflow Prevention
        5. 14.5. Active Directory Weaknesses
        6. 14.6. Hacking PKI
        7. 14.7. Smart Card Hacking
          1. 14.7.1. Smart Card Advantages
          2. 14.7.2. Hardware Reverse Engineering
          3. 14.7.3. EEPROM Trapping
          4. 14.7.4. Power Consumption Analysis
        8. 14.8. Encrypting File System Changes
          1. 14.8.1. Background
          2. 14.8.2. User Interaction
          3. 14.8.3. Data Recovery on Standalone Machines
        9. 14.9. Third-Party Encryption
          1. 14.9.1. Summary of Functionality
          2. 14.9.2. One-Time Password
          3. 14.9.3. Local and Corporate Administrator Recovery
          4. 14.9.4. Authenti-Check Self-Service Password Reset Tool
          5. 14.9.5. User Program Configuration Options
          6. 14.9.6. Network Installation and Updating of User Programs
          7. 14.9.7. Single Sign-On
        10. 14.10. References
      5. 15. SOAP XML Web Services Security
        1. 15.1. XML Encryption
        2. 15.2. XML Signatures
        3. 15.3. Reference
      6. 16. SQL Injection
        1. 16.1. Introduction to SQL
          1. 16.1.1. SQL Commands
          2. 16.1.2. Use of SQL
        2. 16.2. SQL Injection Attacks
          1. 16.2.1. Attack Types
            1. 16.2.1.1. Unauthorized data access
            2. 16.2.1.2. Authentication bypass
            3. 16.2.1.3. Database modification
            4. 16.2.1.4. Escape from a database
          2. 16.2.2. Looking for Errors
        3. 16.3. SQL Injection Defenses
          1. 16.3.1. Obfuscation Defenses
          2. 16.3.2. External Defenses
          3. 16.3.3. Coding Defenses
          4. 16.3.4. Conclusion
        4. 16.4. PHP-Nuke Examples
          1. 16.4.1. Installing PHP-Nuke
          2. 16.4.2. Attacks
          3. 16.4.3. Defenses
        5. 16.5. References
      7. 17. Wireless Security
        1. 17.1. Reducing Signal Drift
        2. 17.2. Problems with WEP
        3. 17.3. Cracking WEP
          1. 17.3.1. Data Analysis
          2. 17.3.2. Wireless Sniffing
            1. 17.3.2.1. Extracting the keystream
          3. 17.3.3. IV Collision
        4. 17.4. Practical WEP Cracking
        5. 17.5. VPNs
          1. 17.5.1. RADIUS
        6. 17.6. TKIP
        7. 17.7. SSL
        8. 17.8. Airborne Viruses
          1. 17.8.1. Embedded Malware Countermeasures
        9. 17.9. References
    7. IV. Advanced Defense
      1. 18. Audit Trail Analysis
        1. 18.1. Log Analysis Basics
        2. 18.2. Log Examples
          1. 18.2.1. Unix
            1. 18.2.1.1. Analysis of Unix logging
          2. 18.2.2. Windows
          3. 18.2.3. Remote Covert Logging
          4. 18.2.4. Other Logging Variations
        3. 18.3. Logging States
        4. 18.4. When to Look at the Logs
        5. 18.5. Log Overflow and Aggregation
        6. 18.6. Challenge of Log Analysis
        7. 18.7. Security Information Management
        8. 18.8. Global Log Aggregation
        9. 18.9. References
      2. 19. Intrusion Detection Systems
        1. 19.1. IDS Examples
          1. 19.1.1. Host IDSs
            1. 19.1.1.1. Logfile monitors
            2. 19.1.1.2. Integrity monitors
          2. 19.1.2. Network IDSs
            1. 19.1.2.1. Signature matchers
            2. 19.1.2.2. Anomaly detectors
        2. 19.2. Bayesian Analysis
          1. 19.2.1. Sensitivity Versus Specificity
            1. 19.2.1.1. Sensitivity
            2. 19.2.1.2. Specificity
            3. 19.2.1.3. Accuracy
          2. 19.2.2. Positive and Negative Predictive Values
          3. 19.2.3. Likelihood Ratios
        3. 19.3. Hacking Through IDSs
          1. 19.3.1. Fragmentation
          2. 19.3.2. Spoofing
          3. 19.3.3. Protocol Mutation
          4. 19.3.4. Attacking Integrity Checkers
        4. 19.4. The Future of IDSs
          1. 19.4.1. Embedded IDS
          2. 19.4.2. Strict Anomaly Detection
          3. 19.4.3. Host- Versus Network-Based IDSs
          4. 19.4.4. Visual Display of Data
        5. 19.5. Snort IDS Case Study
          1. 19.5.1. System Setup
          2. 19.5.2. Alert Viewing Setup
          3. 19.5.3. IDS Rule Tuning
        6. 19.6. IDS Deployment Issues
        7. 19.7. References
      3. 20. Honeypots
        1. 20.1. Motivation
        2. 20.2. Building the Infrastructure
          1. 20.2.1. Procedure
            1. 20.2.1.1. Preparation
            2. 20.2.1.2. Infrastructure systems installation
            3. 20.2.1.3. Victim machine installation
            4. 20.2.1.4. Final steps
        3. 20.3. Capturing Attacks
        4. 20.4. References
      4. 21. Incident Response
        1. 21.1. Case Study: Worm Mayhem
        2. 21.2. Definitions
        3. 21.3. Incident Response Framework
          1. 21.3.1. Preparation
          2. 21.3.2. Identification
          3. 21.3.3. Containment
          4. 21.3.4. Eradication
          5. 21.3.5. Recovery
          6. 21.3.6. Follow-Up
            1. 21.3.6.1. Benefits of the SANS framework
        4. 21.4. Small Networks
        5. 21.5. Medium-Sized Networks
        6. 21.6. Large Networks
          1. 21.6.1. Incident Identification
          2. 21.6.2. Aggressive Response
          3. 21.6.3. Recovery
        7. 21.7. References
      5. 22. Forensics and Antiforensics
        1. 22.1. Hardware Review
          1. 22.1.1. Hard Drives
          2. 22.1.2. RAM
        2. 22.2. Information Detritus
        3. 22.3. Forensics Tools
          1. 22.3.1. WinHex
        4. 22.4. Bootable Forensics CD-ROMs
          1. 22.4.1. Biatchux/FIRE
          2. 22.4.2. ForensiX
        5. 22.5. Evidence Eliminator
          1. 22.5.1. Swap Files
          2. 22.5.2. Temporary Files
          3. 22.5.3. Windows Registry Streams
          4. 22.5.4. Clipboard
          5. 22.5.5. Chat Logs
          6. 22.5.6. Browser Garbage (Internet Explorer)
          7. 22.5.7. Options for Netscape Navigator Users
            1. 22.5.7.1. Setting up Netscape paths
        6. 22.6. Forensics Case Study: FTP Attack
          1. 22.6.1. Introduction
          2. 22.6.2. The Investigation
        7. 22.7. References
    8. V. Appendix
      1. A. Useful SoftICE Commands and Breakpoints
        1. A.1. SoftICE Commands
        2. A.2. Breakpoints
          1. A.2.1. General
            1. A.2.1.1. Time-related
            2. A.2.1.2. Disk access
            3. A.2.1.3. File-related
            4. A.2.1.4. INI files-related
            5. A.2.1.5. Registry-related
    9. About the Authors
    10. Colophon
    11. SPECIAL OFFER: Upgrade this ebook with O’Reilly