Gray hat C# : a hacker's guide to creating and automating security tools / by Brandon Perry.

Perry, Brandon, author.
San Francisco : No Starch Press, Inc., [2017]
1 online resource (xxi, 275 pages) : illustrations
1st edition

Location Notes Your Loan Policy


Other Title:
Gray hat C sharp
C# (Computer program language).
Automatic control -- Computer programs.
Computer security.
Electronic books.
System Details:
text file
Learn to use C#'s powerful set of core libraries to automate tedious yet important tasks like fuzzing, performing vulnerability scans, and analyzing malware. With some help from Mono, you'll write your own practical security tools that will run on Windows, OS X, Linux, and even mobile devices. After a crash course in C# and some of its advanced features, you'll learn how to: Write fuzzers that use the HTTP and XML libraries to scan for SQL and XSS injections Generate shellcode in Metasploit to create cross-platform and cross-architecture payloads Automate Nessus, OpenVAS, and sqlmap to scan for vulnerabilities and exploit SQL injections Write a .NET decompiler for OS X and Linux Parse and read offline registry hives to dump system information Automate the security tools Arachni and Metasploit using their MSGPACK RPCs Streamline and simplify your workday by making the most of C#'s extensive repertoire of powerful tools and libraries with Gray Hat C# .
Title Page
Copyright Page
Brief Contents
Contents in Detail
Foreword by Matt Graeber
Why Should I Trust Mono?
Who Is This Book For?
Organization of This Book
A Final Note
Chapter 1: C# Crash Course
Choosing an IDE
A Simple Example
Introducing Classes and Interfaces
Creating a Class
Creating an Interface
Subclassing from an Abstract Class and Implementing an Interface
Tying Everything Together with the Main() Method
Running the Main() Method
Anonymous Methods
Assigning a Delegate to a Method
Updating the Firefighter Class
Creating Optional Arguments
Updating the Main() Method
Running the Updated Main() Method
Integrating with Native Libraries
Chapter 2: Fuzzing and Exploiting XSS and SQL Injection
Setting Up the Virtual Machine
Adding a Host-Only Virtual Network
Creating the Virtual Machine
Booting the Virtual Machine from the BadStore ISO
SQL Injections
Cross-Site Scripting
Fuzzing GET Requests with a Mutational Fuzzer
Tainting the Parameters and Testing for Vulnerabilities
Building the HTTP Requests
Testing the Fuzzing Code
Fuzzing POST Requests
Writing a POST Request Fuzzer
The Fuzzing Begins
Fuzzing Parameters
Fuzzing JSON
Setting Up the Vulnerable Appliance
Capturing a Vulnerable JSON Request
Creating the JSON Fuzzer
Testing the JSON Fuzzer
Exploiting SQL Injections
Performing a UNION-Based Exploit by Hand
Performing a UNION-Based Exploit Programmatically
Exploiting Boolean-Blind SQL Vulnerabilities
Chapter 3: Fuzzing SOAP Endpoints
Setting Up the Vulnerable Endpoint
Parsing the WSDL
Creating a Class for the WSDL Document
Writing the Initial Parsing Methods
Writing a Class for the SOAP Type and Parameters.
Creating the SoapMessage Class to Define Sent Data
Implementing a Class for Message Parts
Defining Port Operations with the SoapPortType Class
Implementing a Class for Port Operations
Defining Protocols Used in SOAP Bindings
Compiling a List of Operation Child Nodes
Finding the SOAP Services on Ports
Automatically Fuzzing the SOAP Endpoint for SQL Injection Vulnerabilities
Fuzzing Individual SOAP Services
Fuzzing the HTTP POST SOAP Port
Fuzzing the SOAP XML Port
Running the Fuzzer
Chapter 4: Writing Connect-Back, Binding, and Metasploit Payloads
Creating a Connect-Back Payload
The Network Stream
Running the Command
Running the Payload
Binding a Payload
Accepting Data, Running Commands, and Returning Output
Executing Commands from the Stream
Using UDP to Attack a Network
The Code for the Target's Machine
The Attacker's Code
Running x86 and x86-64 Metasploit Payloads from C#
Setting Up Metasploit
Generating Payloads
Executing Native Windows Payloads as Unmanaged Code
Executing Native Linux Payloads
Chapter 5: Automating Nessus
REST and the Nessus API
The NessusSession Class
Making the HTTP Requests
Logging Out and Cleaning Up
Testing the NessusSession Class
The NessusManager Class
Performing a Nessus Scan
Chapter 6: Automating Nexpose
Installing Nexpose
Activation and Testing
Some Nexpose Parlance
The NexposeSession Class
The ExecuteCommand() Method
Logging Out and Disposing of Our Session
Finding the API Version
Driving the Nexpose API
The NexposeManager Class
Automating a Vulnerability Scan
Creating a Site with Assets
Starting a Scan
Creating a PDF Site Report and Deleting the Site
Putting It All Together
Starting the Scan.
Generating a Report and Deleting the Site
Running the Automation
Chapter 7: Automating OpenVAS
Installing OpenVAS
Building the Classes
The OpenVASSession Class
Authenticating with the OpenVAS Server
Creating a Method to Execute OpenVAS Commands
Reading the Server Message
Setting Up the TCP Stream to Send and Receive Commands
Certificate Validation and Garbage Collection
Getting the OpenVAS Version
The OpenVASManager Class
Getting Scan Configurations and Creating Targets
Wrapping Up the Automation
Running the Automation
Chapter 8: Automating Cuckoo Sandbox
Setting Up Cuckoo Sandbox
Manually Running the Cuckoo Sandbox API
Starting the API
Checking Cuckoo's Status
Creating the CuckooSession Class
Writing the ExecuteCommand() Methods to Handle HTTP Requests
Creating Multipart HTTP Data with the GetMultipartFormData() Method
Processing File Data with the FileParameter Class
Testing the CuckooSession and Supporting Classes
Writing the CuckooManager Class
Writing the CreateTask() Method
The Task Details and Reporting Methods
Creating the Task Abstract Class
Sorting and Creating Different Class Types
Putting It Together
Testing the Application
Chapter 9: Automating Sqlmap
Running sqlmap
The sqlmap REST API
Testing the sqlmap API with curl
Creating a Session for sqlmap
Creating a Method to Execute a GET Request
Executing a POST Request
Testing the Session Class
The SqlmapManager Class
Listing sqlmap Options
Making a Method to Perform Scans
The New Main() Method
Reporting on a Scan
Automating a Full sqlmap Scan
Integrating sqlmap with the SOAP Fuzzer
Adding sqlmap GET Request Support to the SOAP Fuzzer
Adding sqlmap POST Request Support
Calling the New Methods.
Chapter 10: Automating ClamAV
Installing ClamAV
The ClamAV Native Library vs. the clamd Network Daemon
Automating with ClamAV's Native Library
Setting Up the Supporting Enumerations and Classes
Accessing ClamAV's Native Library Functions
Compiling the ClamAV Engine
Scanning Files
Cleaning Up
Testing the Program by Scanning the EICAR File
Automating with clamd
Installing the clamd Daemon
Starting the clamd Daemon
Creating a Session Class for clamd
Creating a clamd Manager Class
Testing with clamd
Chapter 11: Automating Metasploit
Running the RPC Server
Installing Metasploitable
Getting the MSGPACK Library
Installing the NuGet Package Manager for MonoDevelop
Installing the MSGPACK Library
Referencing the MSGPACK Library
Writing the MetasploitSession Class
Creating the Execute() Method for HTTP Requests and Interacting with MSGPACK
Transforming Response Data from MSGPACK
Testing the session Class
Writing the MetasploitManager Class
Putting It All Together
Running the Exploit
Interacting with the Shell
Popping Shells
Chapter 12: Automating Arachni
Installing Arachni
The Arachni REST API
Creating the ArachniHTTPSession Class
Creating the ArachniHTTPManager Class
Putting the Session and Manager Classes Together
The Arachni RPC
Manually Running the RPC
The ArachniRPCSession Class
The Supporting Methods for ExecuteCommand()
The ExecuteCommand() Method
The ArachniRPCManager Class
Putting It All Together
Chapter 13: Decompiling and Reversing Managed Assemblies
Decompiling Managed Assemblies
Testing the Decompiler
Using monodis to Analyze an Assembly
Chapter 14: Reading Offline Registry Hives
The Registry Hive Structure.
Getting the Registry Hives
Reading the Registry Hive
Creating a Class to Parse a Registry Hive File
Creating a Class for Node Keys
Making a Class to Store Value Keys
Testing the Library
Dumping the Boot Key
The GetBootKey() Method
The GetValueKey() Method
The GetNodeKey() Method
The StringToByteArray() Method
Getting the Boot Key
Verifying the Boot Key
Chapter 8: Automating Cuckoo Sandbox.
Includes bibliographical references and index.
Description based on print version record.