Black Hat Go

Book description

Black Hat Go explores the darker side of Go, the popular programming language revered by hackers for its simplicity, efficiency, and reliability. It provides an arsenal of practical tactics from the perspective of security practitioners and hackers to help you test your systems, build and automate tools to fit your needs, and improve your offensive security skillset, all using the power of Go.

You’ll begin your journey with a basic overview of Go’s syntax and philosophy and then start to explore examples that you can leverage for tool development, including common network protocols like HTTP, DNS, and SMB. You’ll then dig into various tactics and problems that penetration testers encounter, addressing things like data pilfering, packet sniffing, and exploit development. You’ll create dynamic, pluggable tools before diving into cryptography, attacking Microsoft Windows, and implementing steganography.

You'll learn how to:

•Make performant tools that can be used for your own security projects

•Create usable tools that interact with remote APIs

•Scrape arbitrary HTML data

•Use Go’s standard package, net/http, for building HTTP servers

•Write your own DNS server and proxy

•Use DNS tunneling to establish a C2 channel out of a restrictive network

•Create a vulnerability fuzzer to discover an application’s security weaknesses

•Use plug-ins and extensions to future-proof products

•Use plug-ins and extensions to future-proof products

•Build an RC2 symmetric-key brute-forcer

•Implant data within a Portable Network Graphics (PNG) image

Are you ready to add to your arsenal of security tools? Then let’s Go!

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. About the Authors
  5. BRIEF CONTENTS
  6. CONTENTS IN DETAIL
  7. FOREWORD
  8. ACKNOWLEDGMENTS
  9. INTRODUCTION
    1. Who This Book Is For
    2. What This Book Isn’t
    3. Why Use Go for Hacking?
    4. Why You Might Not Love Go
    5. Chapter Overview
  10. 1 GO FUNDAMENTALS
    1. Setting Up a Development Environment
    2. Understanding Go Syntax
    3. Summary
  11. 2 TCP, SCANNERS, AND PROXIES
    1. Understanding the TCP Handshake
    2. Bypassing Firewalls with Port Forwarding
    3. Writing a TCP Scanner
    4. Building a TCP Proxy
    5. Summary
  12. 3 HTTP CLIENTS AND REMOTE INTERACTION WITH TOOLS
    1. HTTP Fundamentals with Go
    2. Building an HTTP Client That Interacts with Shodan
    3. Interacting with Metasploit
    4. Parsing Document Metadata with Bing Scraping
    5. Summary
  13. 4 HTTP SERVERS, ROUTING, AND MIDDLEWARE
    1. HTTP Server Basics
    2. Credential Harvesting
    3. Keylogging with the WebSocket API
    4. Multiplexing Command-and-Control
    5. Summary
  14. 5 EXPLOITING DNS
    1. Writing DNS Clients
    2. Writing DNS Servers
    3. Summary
  15. 6 INTERACTING WITH SMB AND NTLM
    1. The SMB Package
    2. Understanding SMB
    3. Guessing Passwords with SMB
    4. Reusing Passwords with the Pass-the-Hash Technique
    5. Recovering NTLM Passwords
    6. Summary
  16. 7 ABUSING DATABASES AND FILESYSTEMS
    1. Setting Up Databases with Docker
    2. Connecting and Querying Databases in Go
    3. Building a Database Miner
    4. Pillaging a Filesystem
    5. Summary
  17. 8 RAW PACKET PROCESSING
    1. Setting Up Your Environment
    2. Identifying Devices by Using the pcap Subpackage
    3. Live Capturing and Filtering Results
    4. Sniffing and Displaying Cleartext User Credentials
    5. Port Scanning Through SYN-flood Protections
    6. Summary
  18. 9 WRITING AND PORTING EXPLOIT CODE
    1. Creating a Fuzzer
    2. Porting Exploits to Go
    3. Creating Shellcode in Go
    4. Summary
  19. 10 GO PLUGINS AND EXTENDABLE TOOLS
    1. Using Go’s Native Plug-in System
    2. Building Plug-ins in Lua
    3. Summary
  20. 11 IMPLEMENTING AND ATTACKING CRYPTOGRAPHY
    1. Reviewing Basic Cryptography Concepts
    2. Understanding the Standard Crypto Library
    3. Exploring Hashing
    4. Authenticating Messages
    5. Encrypting Data
    6. Brute-Forcing RC2
    7. Summary
  21. 12 WINDOWS SYSTEM INTERACTION AND ANALYSIS
    1. The Windows API’s OpenProcess() Function
    2. The unsafe.Pointer and uintptr Types
    3. Performing Process Injection with the syscall Package
    4. The Portable Executable File
    5. Using C with Go
    6. Summary
  22. 13 HIDING DATA WITH STEGANOGRAPHY
    1. Exploring the PNG Format
    2. Reading Image Byte Data
    3. Writing Image Byte Data to Implant a Payload
    4. Encoding and Decoding Image Byte Data by Using XOR
    5. Summary
    6. Additional Exercises
  23. 14 BUILDING A COMMAND-AND-CONTROL RAT
    1. Getting Started
    2. Defining and Building the gRPC API
    3. Creating the Server
    4. Creating the Client Implant
    5. Building the Admin Component
    6. Running the RAT
    7. Improving the RAT
    8. Summary
  24. Index

Product information

  • Title: Black Hat Go
  • Author(s): Tom Steele, Chris Patten, Dan Kottmann
  • Release date: January 2020
  • Publisher(s): No Starch Press
  • ISBN: 9781593278656