Foreword |
|
xv | |
|
Acknowledgments |
|
xvii | |
Introduction |
|
xix | |
Who This Book Is For |
|
xx | |
What This Book Isn't |
|
xx | |
Why Use Go for Hacking? |
|
xxi | |
Why You Might Not Love Go |
|
xxi | |
Chapter Overview |
|
xxii | |
|
|
1 | (20) |
|
Setting Up a Development Environment |
|
|
1 | (9) |
|
Downloading and Installing Go |
|
|
2 | (1) |
|
Setting GOROOT to Define the Go Binary Location |
|
|
2 | (1) |
|
Setting GOPATH to Determine the Location of Your Go Workspace |
|
|
2 | (1) |
|
Choosing an Integrated Development Environment |
|
|
3 | (3) |
|
Using Common Go Tool Commands |
|
|
6 | (4) |
|
|
10 | (10) |
|
|
10 | (4) |
|
|
14 | (2) |
|
|
16 | (1) |
|
|
17 | (1) |
|
|
18 | (2) |
|
|
20 | (1) |
|
2 TCP, Scanners, And Proxies |
|
|
21 | (24) |
|
Understanding the TCP Handshake |
|
|
22 | (1) |
|
Bypassing Firewalls with Port Forwarding |
|
|
23 | (1) |
|
|
23 | (9) |
|
Testing for Port Availability |
|
|
24 | (1) |
|
Performing Nonconcurrent Scanning |
|
|
25 | (1) |
|
Performing Concurrent Scanning |
|
|
26 | (6) |
|
|
32 | (12) |
|
Using io.Reader and io.Writer |
|
|
32 | (3) |
|
|
35 | (2) |
|
Improving the Code by Creating a Buffered Listener |
|
|
37 | (2) |
|
|
39 | (1) |
|
Replicating Netcat for Command Execution |
|
|
40 | (4) |
|
|
44 | (1) |
|
3 HTTP Clients And Remote Interaction With Tools |
|
|
45 | (32) |
|
HTTP Fundamentals with Go |
|
|
46 | (5) |
|
|
46 | (2) |
|
|
48 | (1) |
|
Using Structured Response Parsing |
|
|
48 | (3) |
|
Building an HTTP Client That Interacts with Shodan |
|
|
51 | (8) |
|
Reviewing the Steps for Building an API Client |
|
|
51 | (1) |
|
Designing the Project Structure |
|
|
52 | (1) |
|
|
53 | (1) |
|
Querying Your Shodan Subscription |
|
|
54 | (4) |
|
|
58 | (1) |
|
Interacting with Metasploit |
|
|
59 | (9) |
|
Setting Up Your Environment |
|
|
59 | (2) |
|
|
61 | (1) |
|
|
62 | (1) |
|
Defining Request and Response Methods |
|
|
63 | (1) |
|
Creating a Configuration Struct and an RPC Method |
|
|
64 | (1) |
|
|
64 | (3) |
|
Creating a Utility Program |
|
|
67 | (1) |
|
Parsing Document Metadata with Bing Scraping |
|
|
68 | (8) |
|
Setting Up the Environment and Planning |
|
|
69 | (2) |
|
Defining the metadata Package |
|
|
71 | (1) |
|
Mapping the Data to Structs |
|
|
72 | (1) |
|
Searching and Receiving Files with Bing |
|
|
73 | (3) |
|
|
76 | (1) |
|
4 HTTP Servers, Routing, And Middleware |
|
|
77 | (26) |
|
|
78 | (12) |
|
|
78 | (1) |
|
|
79 | (1) |
|
Building Simple Middleware |
|
|
80 | (1) |
|
Routing with the gorilla/mux Package |
|
|
81 | (2) |
|
Building Middleware with Negroni |
|
|
83 | (3) |
|
Adding Authentication with Negroni |
|
|
86 | (2) |
|
Using Templates to Produce HTML Responses |
|
|
88 | (2) |
|
|
90 | (3) |
|
Keylogging with the WebSocket API |
|
|
93 | (5) |
|
Multiplexing Command-and-Control |
|
|
98 | (4) |
|
|
102 | (1) |
|
|
103 | (28) |
|
|
104 | (13) |
|
|
104 | (2) |
|
Processing Answers from a Msg struct |
|
|
106 | (1) |
|
|
107 | (10) |
|
|
117 | (13) |
|
Lab Setup and Server Introduction |
|
|
118 | (3) |
|
Creating DNS Server and Proxy |
|
|
121 | (9) |
|
|
130 | (1) |
|
6 Interacting With Smb And NTLM |
|
|
131 | (22) |
|
|
132 | (1) |
|
|
132 | (14) |
|
Understanding SMB Security Tokens |
|
|
133 | (1) |
|
Setting Up an SMB Session |
|
|
134 | (1) |
|
Using Mixed Encoding of Struct Fields |
|
|
135 | (3) |
|
Understanding Metadata and Referential Fields |
|
|
138 | (1) |
|
Understanding the SMB Implementation |
|
|
139 | (7) |
|
Guessing Passwords with SMB |
|
|
146 | (1) |
|
Reusing Passwords with the Pass-the-Hash Technique |
|
|
147 | (3) |
|
Recovering NTLM Passwords |
|
|
150 | (1) |
|
|
150 | (1) |
|
|
150 | (1) |
|
|
151 | (2) |
|
7 Abusing Databases And Filesystems |
|
|
153 | (20) |
|
Setting Up Databases with Docker |
|
|
154 | (4) |
|
Installing and Seeding MongoDB |
|
|
154 | (2) |
|
Installing and Seeding PostgreSQL and MySQL Databases |
|
|
156 | (1) |
|
Installing and Seeding Microsoft SQL Server Databases |
|
|
157 | (1) |
|
Connecting and Querying Databases in Go |
|
|
158 | (3) |
|
|
158 | (2) |
|
|
160 | (1) |
|
Building a Database Miner |
|
|
161 | (9) |
|
Implementing a MongoDB Database Miner |
|
|
164 | (2) |
|
Implementing a MySQL Database Miner |
|
|
166 | (4) |
|
|
170 | (2) |
|
|
172 | (1) |
|
|
173 | (14) |
|
Setting Up Your Environment |
|
|
174 | (1) |
|
Identifying Devices by Using the pcap Subpackage |
|
|
174 | (1) |
|
Live Capturing and Filtering Results |
|
|
175 | (3) |
|
Sniffing and Displaying Cleartext User Credentials |
|
|
178 | (2) |
|
Port Scanning Through SYN-flood Protections |
|
|
180 | (5) |
|
|
180 | (1) |
|
|
181 | (1) |
|
|
182 | (3) |
|
|
185 | (2) |
|
9 Writing And Porting Exploit Code |
|
|
187 | (30) |
|
|
88 | (108) |
|
|
188 | (4) |
|
|
192 | (4) |
|
|
196 | (17) |
|
Porting an Exploit from Python |
|
|
197 | (4) |
|
Porting an Exploit from C |
|
|
201 | (12) |
|
|
213 | (3) |
|
|
213 | (1) |
|
|
214 | (1) |
|
|
214 | (1) |
|
|
215 | (1) |
|
|
215 | (1) |
|
|
216 | (1) |
|
|
216 | (1) |
|
10 Go Plugins And Extendable Tools |
|
|
217 | (16) |
|
Using Go's Native Plug-in System |
|
|
218 | (7) |
|
Creating the Main Program |
|
|
219 | (3) |
|
Building a Password-Guessing Plug-in |
|
|
222 | (2) |
|
|
224 | (1) |
|
|
225 | (7) |
|
Creating the head() HTTP Function |
|
|
226 | (1) |
|
Creating the get() Function |
|
|
227 | (2) |
|
Registering the Functions with the Lua VM |
|
|
229 | (1) |
|
Writing Your Main Function |
|
|
230 | (1) |
|
Creating Your Plug-in Script |
|
|
231 | (1) |
|
|
232 | (1) |
|
|
232 | (1) |
|
11 Implementing And Attacking Cryptography |
|
|
233 | (30) |
|
Reviewing Basic Cryptography Concepts |
|
|
234 | (1) |
|
Understanding the Standard Crypto Library |
|
|
235 | (1) |
|
|
235 | (4) |
|
Cracking an MD5 or SHA-256 Hash |
|
|
236 | (1) |
|
|
237 | (2) |
|
|
239 | (3) |
|
|
242 | (10) |
|
|
242 | (3) |
|
|
245 | (7) |
|
|
252 | (9) |
|
|
252 | (3) |
|
|
255 | (2) |
|
Performing Work and Decrypting Data |
|
|
257 | (1) |
|
Writing the Main Function |
|
|
258 | (2) |
|
|
260 | (1) |
|
|
261 | (2) |
|
12 Windows System Interaction And Analysis |
|
|
263 | (32) |
|
The Windows API's OpenProcessj) Function |
|
|
263 | (3) |
|
The unsafe.Pointer and uintptr Types |
|
|
266 | (2) |
|
Performing Process Injection with the syscall Package |
|
|
268 | (11) |
|
Defining the Windows DLLs and Assigning Variables |
|
|
270 | (1) |
|
Obtaining a Process Token with the OpenProcess Windows API |
|
|
271 | (2) |
|
Manipulating Memory with the VirtualAllocEx Windows API |
|
|
273 | (1) |
|
Writing to Memory with the WriteProcessMemory Windows API |
|
|
274 | (1) |
|
Finding LoadLibraryA with the GetProcessAddress Windows API |
|
|
275 | (1) |
|
Executing the Malicious DLL Using the CreateRemoteThread Windows API |
|
|
275 | (1) |
|
Verifying Injection with the WaitforSingleObject Windows API |
|
|
276 | (1) |
|
Cleaning Up with the VirtualFreeEx Windows API |
|
|
277 | (1) |
|
|
278 | (1) |
|
The Portable Executable File |
|
|
279 | (11) |
|
Understanding the PE File Format |
|
|
279 | (1) |
|
|
280 | (9) |
|
|
289 | (1) |
|
|
290 | (3) |
|
Installing a C Windows Toolchain |
|
|
290 | (1) |
|
Creating a Message Box Using C and the Windows API |
|
|
290 | (1) |
|
|
291 | (2) |
|
|
293 | (2) |
|
13 Hiding Data With Steganography |
|
|
295 | (20) |
|
|
296 | (2) |
|
|
296 | (1) |
|
|
297 | (1) |
|
|
298 | (4) |
|
|
298 | (1) |
|
Reading the Chunk Sequence |
|
|
299 | (3) |
|
Writing Image Byte Data to Implant a Payload |
|
|
302 | (5) |
|
|
302 | (1) |
|
Writing Bytes with the Processlmage() Method |
|
|
302 | (5) |
|
Encoding and Decoding Image Byte Data by Using XOR |
|
|
307 | (5) |
|
|
312 | (1) |
|
|
312 | (3) |
|
14 Building A Command-And-Control Rat |
|
|
315 | (16) |
|
|
316 | (1) |
|
Installing Protocol Buffers for Defining a gRPC API |
|
|
316 | (1) |
|
Creating the Project Workspace |
|
|
317 | (1) |
|
Defining and Building the gRPC API |
|
|
317 | (2) |
|
|
319 | (4) |
|
Implementing the Protocol Interface |
|
|
319 | (3) |
|
Writing the main() Function |
|
|
322 | (1) |
|
Creating the Client Implant |
|
|
323 | (2) |
|
Building the Admin Component |
|
|
325 | (1) |
|
|
326 | (1) |
|
|
326 | (4) |
|
Encrypt Your Communications |
|
|
327 | (1) |
|
Handle Connection Disruptions |
|
|
327 | (1) |
|
|
327 | (1) |
|
|
328 | (1) |
|
Support Multiple Implants |
|
|
328 | (1) |
|
Add Implant Functionality |
|
|
329 | (1) |
|
Chain Operating System Commands |
|
|
329 | (1) |
|
Enhance the Implant's Authenticity and Practice Good OPSEC |
|
|
329 | (1) |
|
|
329 | (1) |
|
|
330 | (1) |
Index |
|
331 | |