Title Page....15
Copyright Page....16
About the Authors....18
BRIEF CONTENTS....21
CONTENTS IN DETAIL....22
FOREWORD....30
ACKNOWLEDGMENTS....33
INTRODUCTION....36
Who This Book Is For....37
What This Book Isn’t....38
Why Use Go for Hacking?....39
Why You Might Not Love Go....40
Chapter Overview....41
1 GO FUNDAMENTALS....48
Setting Up a Development Environment....48
Understanding Go Syntax....64
Summary....81
2 TCP, SCANNERS, AND PROXIES....82
Understanding the TCP Handshake....83
Bypassing Firewalls with Port Forwarding....85
Writing a TCP Scanner....86
Building a TCP Proxy....100
Summary....120
3 HTTP CLIENTS AND REMOTE INTERACTION WITH TOOLS....121
HTTP Fundamentals with Go....122
Building an HTTP Client That Interacts with Shodan....130
Interacting with Metasploit....144
Parsing Document Metadata with Bing Scraping....160
Summary....173
4 HTTP SERVERS, ROUTING, AND MIDDLEWARE....174
HTTP Server Basics....175
Credential Harvesting....196
Keylogging with the WebSocket API....202
Multiplexing Command-and-Control....211
Summary....218
5 EXPLOITING DNS....219
Writing DNS Clients....220
Writing DNS Servers....242
Summary....263
6 INTERACTING WITH SMB AND NTLM....265
The SMB Package....266
Understanding SMB....267
Guessing Passwords with SMB....290
Reusing Passwords with the Pass-the-Hash Technique....292
Recovering NTLM Passwords....297
Summary....299
7 ABUSING DATABASES AND FILESYSTEMS....301
Setting Up Databases with Docker....302
Connecting and Querying Databases in Go....310
Building a Database Miner....315
Pillaging a Filesystem....328
Summary....331
8 RAW PACKET PROCESSING....332
Setting Up Your Environment....333
Identifying Devices by Using the pcap Subpackage....334
Live Capturing and Filtering Results....336
Sniffing and Displaying Cleartext User Credentials....340
Port Scanning Through SYN-flood Protections....344
Summary....352
9 WRITING AND PORTING EXPLOIT CODE....353
Creating a Fuzzer....353
Porting Exploits to Go....369
Creating Shellcode in Go....396
Summary....402
10 GO PLUGINS AND EXTENDABLE TOOLS....403
Using Go’s Native Plug-in System....404
Building Plug-ins in Lua....416
Summary....428
11 IMPLEMENTING AND ATTACKING CRYPTOGRAPHY....430
Reviewing Basic Cryptography Concepts....431
Understanding the Standard Crypto Library....433
Exploring Hashing....434
Authenticating Messages....441
Encrypting Data....445
Brute-Forcing RC2....463
Summary....478
12 WINDOWS SYSTEM INTERACTION AND ANALYSIS....479
The Windows API’s OpenProcess() Function....480
The unsafe.Pointer and uintptr Types....484
Performing Process Injection with the syscall Package....489
The Portable Executable File....506
Using C with Go....526
Summary....532
13 HIDING DATA WITH STEGANOGRAPHY....534
Exploring the PNG Format....535
Reading Image Byte Data....538
Writing Image Byte Data to Implant a Payload....545
Encoding and Decoding Image Byte Data by Using XOR....554
Summary....562
Additional Exercises....563
14 BUILDING A COMMAND-AND-CONTROL RAT....565
Getting Started....566
Defining and Building the gRPC API....568
Creating the Server....572
Creating the Client Implant....579
Building the Admin Component....582
Running the RAT....584
Improving the RAT....585
Summary....591
Index....593
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.
Are you ready to add to your arsenal of security tools? Then let's Go!