Share E-Book

Red Team Engineering The Art of Building Offensive Tools and Infrastructure (Casey Erdmann)(Z-Library)

Author

Rating No ratings yet

Log in to rate

Cybersecurity
Language English

Stop Relying on Black Box Tools and Start Building Your Own. Offensive security isn’t just about running scripts; it’s about implementing engineering solutions. Red Team Engineering will show you how to transition from penetration tester to red team operator—taking you beyond the basics of exploitation to teach you the “how” of professional offensive development and infrastructure engineering. Casey Erdmann, an experienced red team operator, guides you through the complete development life cycle of a modern cyber operation. Using a project-based approach, you’ll engineer a complete offensive arsenal as you: Build full-stack credential harvesting apps with HTML, JavaScript, PHP, and MySQL. Create brute-force and password-spraying tools in Python to attack SMB services. Use Go to craft custom ransomware with encryption/decryption logic. Abandon manual server setups for reproducible, disposable infrastructure. Deploy C2 servers, redirectors, and phishing infrastructure on AWS. You’ll also learn how to: Tunnel through firewalls with reverse VPNs using OpenVPN and PiVPN. Manage fleet configurations at scale with Salt Project. Simulate execution of end-to-end scenarios like deploying a physical “dropbox.” Whether your goal is to understand the enemy or to level up your penetration testing skills, Red Team Engineering will show you how to build professional-grade hacking tools that get the job done.

Format PDF
Size 4.6 MB
8
Views
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
® Casey Erdmann
Page 2
(This page has no text content)
Page 3
RED TEAM ENGINEERING
Page 4
(This page has no text content)
Page 5
® R E D T E A M E N G I N E E R I N G T h e A r t o f B u i l d i n g O f f e n s i v e To o l s a n d I n f r a s t r u c t u r e Casey Erdmann San Francisco
Page 6
[E] RED TEAM ENGINEERING. Copyright © 2026 by Casey Erdmann. All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. First printing 30 29 28 27 26 1 2 3 4 5 ISBN-13: 978-1-7185-0426-4 (print) ISBN-13: 978-1-7185-0427-1 (ebook) Published by No Starch Press®, Inc. 245 8th Street, San Francisco, CA 94103 phone: +1.415.863.9900 www .nostarch .com; info@nostarch .com Publisher: William Pollock Managing Editor: Jill Franklin Production Manager: Sabrina Plomitallo-González Production Editor: Allison Felus Developmental Editor: Rachel Monaghan Cover Illustrator: Rick Reese Interior Design: Octopod Studios Technical Reviewer: Cliff Janzen Copyeditor: Sharon Wilkey Proofreader: Cindy Snyder Indexer: BIM Creatives, LLC Library of Congress Control Number: 2025947798 For customer service inquiries, please contact info@nostarch .com. For information on distribution, bulk sales, corporate sales, or translations: sales@nostarch .com. For permission to translate this work: rights@nostarch .com. To report counterfeit copies or piracy: counterfeit@nostarch .com. The authorized representative in the EU for product safety and compliance is EU Compliance Partner, Pärnu mnt. 139b-14, 11317 Tallinn, Estonia, hello@eucompliancepartner .com, +3375690241. No Starch Press and the No Starch Press iron logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it. ™
Page 7
This book is dedicated to you, the hacker.
Page 8
(This page has no text content)
Page 9
About the Author Casey Erdmann began his professional career as a system administrator’s assistant, then moved into software development before entering the secu- rity field. Today he is a top-level offensive security professional specializing in custom tool development and post-exploitation techniques. He has built and managed teams, taught courses online, and spoken at universities. Above all else, Casey is a hacker. He has published countless tools and exploits used by teams all over the world. He is committed to improving processes and workflows by figuring out how to make things work in ways that may not have been intended. When he’s not hacking, Casey spends time with his dogs, Echo and Luna. He also enjoys making music and relaxing with a glass of bourbon and a good book. Read more about Casey on his company website, Injection Software and Security, LLC (https://injection.sh), or listen to his podcast Echo’s Box (https://echosbox.com). About the Technical Reviewer Since the early days of Commodore PET and VIC-20, technology has been a constant companion (and sometimes an obsession!) for Cliff Janzen. Based in Regina, Saskatchewan, Cliff currently works as a chief information secu- rity officer and vice president of cybersecurity services. He is grateful to have had the opportunity to work with and learn from some of the best people in the industry, including Casey Erdmann and the fine people at No Starch Press. Cliff feels lucky to have a career that is also his favorite hobby and a wife who supports him.
Page 10
(This page has no text content)
Page 11
B R I E F C O N T E N T S Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Chapter 0: Tools of the Tradecraft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii PART I: OFFENSIVE SECURITY DEVELOPMENT . . . . . . . . . . . . . . . . . . . . . .1 Chapter 1: Web Application Exploits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Chapter 2: Authentication Attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Chapter 3: Custom Malware Development and Distribution . . . . . . . . . . . . . . . . . . . . . . . . 97 PART II: OFFENSIVE SECURITY ENGINEERING . . . . . . . . . . . . . . . . . . . .155 Chapter 4: Automating Offensive Security Infrastructure Deployment . . . . . . . . . . . . . . . . 157 Chapter 5: Applying Network Fundamentals to C2 Implementation . . . . . . . . . . . . . . . . . 179 Chapter 6: Reverse VPN Tunneling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 Chapter 7: Managing Infrastructure for Offensive Security Operations . . . . . . . . . . . . . . . 205 PART III: OFFENSIVE SECURITY IN THE REAL WORLD . . . . . . . . . . . . . . .221 Chapter 8: Exploitation with Metasploit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 Chapter 9: Deploying a Dropbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 Chapter 10: Phishing Attack with C2 Redirectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Chapter 11: Multiplayer C2 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Page 12
(This page has no text content)
Page 13
C O N T E N T S I N D E T A I L ACKNOWLEDGMENTS xvii INTRODUCTION xix Core Concepts of Offensive Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx Ethical Implications of Red Teaming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi Red Team Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii What You’ll Need to Follow Along . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiii How This Book Is Organized . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiv 0 TOOLS OF THE TRADECRAFT xxvii PART I: OFFENSIVE SECURITY DEVELOPMENT 1 1 WEB APPLICATION EXPLOITS 3 Considering OST Best Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Building a Basic Phishing Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Using Bootstrap and Font Awesome CSS for a Modern-Looking Site . . . . . . . . . 5 Importing JavaScript Libraries via CDNs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Adding a Navigation Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Creating a Credential-Harvesting Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Handling Credentials with JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Capturing Credentials Server-Side with PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Saving Credentials Without a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Creating a MySQL Database for Credential Storage . . . . . . . . . . . . . . . . . . . . . . . . . 24 Building a Phishing Website with Database Credential Storage . . . . . . . . . . . . . . . . . . 28 Capturing Credentials with JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Exploring Common Tools for Phishing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 The wget Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 The goclone Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 AI, LLMs, and ChatGPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 EAPHammer Captive-Portal Attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Going Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 2 AUTHENTICATION ATTACKS 49 Creating a Target Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Adding Authentication with PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Preventing SQL Injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Page 14
xii   Contents in Detail Implementing a Login Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Following Best Practices for Credential Storage . . . . . . . . . . . . . . . . . . . . . . . 54 Dissecting Requests with DevTools and Proxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Identifying Data with Web Developer Tools . . . . . . . . . . . . . . . . . . . . . . . . . 55 Intercepting Requests with a Web Proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Handling Proxied Requests with Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Sending a Transparent Proxy Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Building a Proxy Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Brute-Forcing Credentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Building the Login Request Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Sending Authentication Data with Python . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Automating the Brute-Force Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Running a Brute-Force Attack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Creating a Web Application Password-Spraying Tool . . . . . . . . . . . . . . . . . . . . . . . . . 70 Building the Password-Spraying Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 Running the Password-Spraying Attack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Creating an SMB Brute-Forcing Attack Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Implementing the SMB Connection in Python . . . . . . . . . . . . . . . . . . . . . . . . 74 Validating Successful Authentication to SMB Shares . . . . . . . . . . . . . . . . . . . . 76 Automating the Brute-Force Attack for SMB Targets . . . . . . . . . . . . . . . . . . . . 77 Running a Brute-Force Attack Against SMB . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Creating an SMB Password-Spraying Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Implementing a Password-Spraying Loop for SMB Targets . . . . . . . . . . . . . . . 80 Running a Password Spray Against SMB . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Common Tools for Authentication Attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Burp Suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 CrackMapExec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Spray Wrapper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 3 CUSTOM MALWARE DEVELOPMENT AND DISTRIBUTION 97 Writing a Simple Program in Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Setting Up the File-Reading Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Setting Up the File-Writing Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Combining the Reading and Writing Programs . . . . . . . . . . . . . . . . . . . . . . 103 Command Execution with the os Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 File Encryption with Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Building the Encryption Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Building the Decryption Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Writing Custom Ransomware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Defining the Encrypt() and Decrypt() Functions . . . . . . . . . . . . . . . . . . . . . . 121 Scaffolding the Ransomware Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Defining the doEncrypt() and doDecrypt() Functions . . . . . . . . . . . . . . . . . . . 125 Running the Ransomware Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Writing a C2 Server in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Writing a C2 Implant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 AI Malware Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Page 15
Contents in Detail   xiii PART II: OFFENSIVE SECURITY ENGINEERING 155 4 AUTOMATING OFFENSIVE SECURITY INFRASTRUCTURE DEPLOYMENT 157 Tools and Technologies for Automation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 AWS for Attack Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Creating an AWS Service Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 A Terraform Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Terraform Server Instantiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Terraform Network Access Control Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Terraform EC2 Instance Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 Terraform Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 A Serverless Framework Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 Boilerplate Serverless Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Serverless Python Deployment Dependencies . . . . . . . . . . . . . . . . . . . . . . . 174 Serverless Flask API Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Serverless Framework Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 5 APPLYING NETWORK FUNDAMENTALS TO C2 IMPLEMENTATION 179 The OSI Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 Simple Target Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 Active Directory Target Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 Command-and-Control Network Flows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Bind Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 Reverse Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 Exploitation with the Metasploit Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 Executing a Bind Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Executing a Reverse Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 The Implications of Connection Directionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 6 REVERSE VPN TUNNELING 191 Reverse VPN Topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 Compromising a Server for Reverse VPN Tunneling . . . . . . . . . . . . . . . . . . . 192 Using Reverse VPN Tunnel Path Topology . . . . . . . . . . . . . . . . . . . . . . . . . . 193 Configuring an EC2 Instance with Terraform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 Accessing the Reverse VPN Server Instance . . . . . . . . . . . . . . . . . . . . . . . . 195 Simulating a Dropbox with Vagrant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Configuring OpenVPN with PiVPN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Selecting OpenVPN Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Configuring OpenVPN Service and DNS . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Setting OpenVPN Encryption Strength . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 Setting OpenVPN Post-Installation Configurations . . . . . . . . . . . . . . . . . . . . 200
Page 16
xiv   Contents in Detail Generating a VPN Certificate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 Establishing a Reverse VPN Tunnel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 A Note on Automation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 7 MANAGING INFRASTRUCTURE FOR OFFENSIVE SECURITY OPERATIONS 205 The Evolution of Infrastructure Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 Getting Started with Salt Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 Configuring the Salt Project Terraform Server . . . . . . . . . . . . . . . . . . . . . . . 207 Installing Salt Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Configuring the Salt Fingerprint and IP Address . . . . . . . . . . . . . . . . . . . . . 210 Linking the Minions to the Master . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 Running a Salt Project Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Working with Salt States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Creating a Salt State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 Observing Desired State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 Salt Project as a C2 Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 PART III: OFFENSIVE SECURITY IN THE REAL WORLD 221 8 EXPLOITATION WITH METASPLOIT 225 Gaining Access: Configuring a C2 Server with Terraform . . . . . . . . . . . . . . . . . . . . . 226 Spinning Up Metasploit on a C2 Server . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Setting Up the Exploit Callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 Exploiting the Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 Maintaining Access: Establishing Persistence with Metasploit . . . . . . . . . . . . . . . . . . . 233 Disabling Windows Defender . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 Generating a Meterpreter Payload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 Configuring Persistence Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 Using the Metasploit Cleanup Automation Resource . . . . . . . . . . . . . . . . . . 239 Acting on the Objective: Extracting Credentials with Mimikatz . . . . . . . . . . . . . . . . . . 239 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 9 DEPLOYING A DROPBOX 243 Configuring a Reverse VPN Dropbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 Using Empire on a C2 Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 Configuring Empire . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 Preparing an Empire C2 Stager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 Post-Exploitation via Python Impacket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 Deploying the Empire Stager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 Establishing Persistence via Empire . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Page 17
Contents in Detail   xv 10 PHISHING ATTACK WITH C2 REDIRECTORS 255 Preparing Your Custom C2 Implant and Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 Implementing C2 Redirectors via the Serverless Framework . . . . . . . . . . . . . . . . . . . . 259 Creating an AWS Lambda Redirector in Python . . . . . . . . . . . . . . . . . . . . . 260 Deploying the Redirector to AWS Lambda . . . . . . . . . . . . . . . . . . . . . . . . . 262 Configuring a Custom C2 Server and Implant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 Configuring Gophish . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 Creating the Gophish Service Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 Installing Gophish and Configuring Program Permissions . . . . . . . . . . . . . . . 265 Setting Up an SSH Proxy to the Gophish Admin Panel . . . . . . . . . . . . . . . . . 266 Configuring the Gophish Admin Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 Creating and Launching a Gophish Campaign . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 Cloning a Landing Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 Creating a Phishing Email Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 Configuring an SMTP Sending Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 Executing the Campaign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 Phishing Payload Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 Receiving a Custom Simple C2 Callback . . . . . . . . . . . . . . . . . . . . . . . . . . 282 Red Team Infrastructure in the Real World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 11 MULTIPLAYER C2 CONFIGURATION 285 teamserver for Cobalt Strike and Armitage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 Starting the Metasploit Database and teamserver . . . . . . . . . . . . . . . . . . . . 286 Connecting to teamserver with Armitage . . . . . . . . . . . . . . . . . . . . . . . . . . 287 Interacting with teamserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 Multiplayer Mode for Sliver C2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 Installing Sliver C2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 Configuring Multiplayer Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 Getting a Callback with Sliver C2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Other Multiuser C2 Tool Kits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 RESOURCES 297 INDEX 299
Page 18
(This page has no text content)
Page 19
A C K N O W L E D G M E N T S I would like to thank Jon Erickson for writing Hacking: The Art of Exploitation, as well as Joe Vest and James Tubberville for writing Red Team Development and Operations. Without the inspiration of these authors, this book would not exist. I would also like to thank my team at Depth Security for support- ing my endeavors, both professionally and personally. Finally, I would like to thank my dear friends Christopher Lamberson and Robert King, without whom I would never have chosen this career path. You guys rock!
Page 20
(This page has no text content)
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
← Back to List