Offensive Shellcode from Scratch

Book description

Gain practical knowledge of shellcode and leverage it to develop shellcode for Windows and Linux operating systems, while understanding the countermeasures in place and how these can be bypassed

Key Features

  • Get up and running with shellcode fundamentals
  • Develop Shellcode for Windows and Linux
  • Understand the building blocks of shellcode

Book Description

Shellcoding is a technique that is executed by many red teams and used in penetration testing and real-world attacks. Books on shellcode can be complex, and writing shellcode is perceived as a kind of "dark art." Offensive Shellcode from Scratch will help you to build a strong foundation of shellcode knowledge and enable you to use it with Linux and Windows.

This book helps you to explore simple to more complex examples of shellcode that are used by real advanced persistent threat (APT) groups. You'll get to grips with the components of shellcode and understand which tools are used when building shellcode, along with the automated tools that exist to create shellcode payloads. As you advance through the chapters, you'll become well versed in assembly language and its various components, such as registers, flags, and data types. This shellcode book also teaches you about the compilers and decoders that are used when creating shellcode. Finally, the book takes you through various attacks that entail the use of shellcode in both Windows and Linux environments.

By the end of this shellcode book, you'll have gained the knowledge needed to understand the workings of shellcode and build your own exploits by using the concepts explored.

What you will learn

  • Gain a thorough understanding of shellcode
  • Get to grips with assembly language and its key purpose in shellcode development
  • Identify key elements of memory registers
  • Explore debuggers and their use cases
  • Get up and running with hands-on shellcode creation for both Windows and Linux
  • Exploit Windows and Linux operating systems using shellcode
  • Assess countermeasures of Windows and Linux

Who this book is for

This book is for red teamers, penetration testers, and anyone looking to learn about shellcode and find out how it is used to break into systems by making use of simple to complex instructions of code in memory. Basic shellcode knowledge is helpful but not mandatory to understand the topics covered in this book.

Table of contents

  1. Offensive Shellcode from Scratch
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the color images
    5. Conventions used
    6. Get in touch
    7. Share Your Thoughts
  6. Section 1: Shellcode
  7. Chapter 1: The Ins and Outs of Shellcode
    1. What is shellcode?
      1. Examples of shellcode
      2. Shellcode versus a payload
    2. Breaking down shellcode
    3. Exploring the common types of shellcode
      1. Local shellcode
      2. Remote shellcode
    4. Summary
    5. Further reading
  8. Chapter 2: Assembly Language
    1. Technical requirements
    2. Demystifying assembly language
    3. Types of assembly language
    4. Identifying the elements of assembly language
      1. Registers and flags
      2. Data movement instructions
      3. Arithmetic instructions
      4. Conditional instructions
    5. Summary
    6. Further reading
  9. Chapter 3: Shellcode Tools and Resources
    1. Technical requirements
    2. Interpreters, compilers, and assemblers
      1. Interpreters
      2. Compilers
      3. Interpreters versus compilers
      4. Assemblers
    3. Tools and resources for developing shellcode
      1. Netwide Assembler (NASM)
      2. Microsoft Assembler (MASM)
      3. Visual Studio
      4. GNU Compiler
      5. IDA Pro
      6. x64dbg
      7. Shellcode creation tools
      8. Online shellcode resources
    4. Summary
  10. Section 2: Writing Shellcode
  11. Chapter 4: Developing Shellcode for Windows
    1. Technical requirements
    2. Environment setup
      1. Installing Mona
    3. Anatomy of memory
    4. Shellcode techniques
      1. Buffer overflow attacks
      2. Backdooring PE files with shellcode
      3. Egg hunter
    5. Summary
    6. Further reading
  12. Chapter 5: Developing Shellcode for Linux
    1. Technical requirements
    2. Environment setup
    3. Executable and Linking Format (ELF) fundamentals
    4. Shellcode techniques
      1. Basic Linux shellcode
      2. Egg hunter shellcode
      3. Reverse TCP shellcode
      4. Writing shellcode for x64
      5. Format string vulnerabilities
    5. Summary
    6. Further reading
  13. Section 3: Countermeasures and Bypasses
  14. Chapter 6: Countermeasures and Bypasses
    1. Technical requirements
    2. Countermeasures and bypasses for Windows
      1. Address space layout randomization
    3. Data execution prevention
      1. Stack cookies
      2. Structured exception handling
    4. Countermeasures and bypasses for Linux
      1. NoExecute
      2. Address space layout randomization
      3. Relocation read only
    5. Summary
    6. Further reading
    7. Why subscribe?
  15. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Offensive Shellcode from Scratch
  • Author(s): Rishalin Pillay
  • Release date: April 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781803247427