### Build and Install Havoc Framework (Bash) Source: https://context7.com/havocframework/havoc/llms.txt Installs system prerequisites, clones the repository, downloads Go dependencies, and builds the Teamserver and Client binaries. Starts the Teamserver with a profile and debug flags. Ensure Python 3.10 is available on Ubuntu 20.04/22.04. ```bash # Install prerequisites (Debian/Ubuntu) sudo apt install -y git build-essential cmake libfontconfig1 libglu1-mesa-dev \ libgtest-dev libspdlog-dev libboost-all-dev libncurses5-dev libssl-dev \ libreadline-dev libsqlite3-dev qtbase5-dev qtchooser qt5-qmake \ qtbase5-dev-tools libqt5websockets5 libqt5websockets5-dev \ qtdeclarative5-dev golang-go python3-dev mingw-w64 nasm # Ubuntu 20.04/22.04: ensure Python 3.10 is available sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update && sudo apt install python3.10 python3.10-dev # Clone and install Go dependencies git clone https://github.com/HavocFramework/Havoc.git cd Havoc go mod download golang.org/x/sys go mod download github.com/ugorji/go # Build both binaries make ts-build # Teamserver binary → ./havoc make client-build # Client binary → ./havoc # Start the Teamserver (requires root for privileged ports) sudo ./havoc server --profile ./profiles/havoc.yaotl -v --debug # Start the Client (separate terminal) ./havoc client ``` -------------------------------- ### Install go-fuzz and Build Tools Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/hclsyntax/fuzz/README.md Install go-fuzz and its build tools within your GOPATH. This command assumes you have a Makefile available. ```bash $ make tools FUZZ_WORK_DIR=$RAMDISK ``` -------------------------------- ### Start Havoc Client Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Execute the command to launch the Havoc client application. This is the entry point for interacting with the framework's UI. ```bash cd Havoc ./havoc client ``` -------------------------------- ### Install HCL Spec Suite Harness Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/specsuite/README.md Build the harness for running the HCL spec suite using Go. This command installs the `hclspecsuite` executable. ```bash go install Havoc/pkg/profile/yaotl/cmd/hclspecsuite ``` -------------------------------- ### Install Dependencies on Arch-based Distros Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Installs essential development tools and libraries for Havoc on Arch-based Linux distributions. ```bash sudo pacman -S git gcc base-devel cmake fontconfig glu gtest spdlog boost boost-libs ncurses gdbm openssl readline libffi sqlite bzip2 mesa qt5-base qt5-websockets python3 nasm mingw-w64-gcc ``` -------------------------------- ### Install Go Dependencies for Teamserver Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Downloads necessary Go modules required for building the Havoc teamserver. ```go go mod download golang.org/x/sys go mod download github.com/ugorji/go ``` -------------------------------- ### HCL Configuration Example Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/intro.rst Demonstrates a typical HCL configuration with arguments and nested blocks for a hypothetical web proxy service. Use this for hand-written configuration files. ```hcl io_mode = "async" service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "main" { command = ["/usr/local/bin/awesome-app", "server"] } process "mgmt" { command = ["/usr/local/bin/awesome-app", "mgmt"] } } ``` -------------------------------- ### Build and Run Havoc Teamserver Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Installs the musl compiler, builds the teamserver binary, and then runs it with specified profile and debug flags. Requires sudo for execution. ```bash # Install musl Compiler & Build Binary (From Havoc Root Directory) make ts-build # Run the teamserver sudo ./havoc server --profile ./profiles/havoc.yaotl -v --debug ``` -------------------------------- ### Start Teamserver with Profile and Flags Source: https://context7.com/havocframework/havoc/llms.txt Launches the Havoc teamserver binary. Specify the profile path and use flags for verbose, debug, or developer debug output. ```bash # Full usage ./havoc server --profile [flags] # Verbose + debug output (recommended during development) sudo ./havoc server --profile ./profiles/havoc.yaotl --verbose --debug # Enable dev debug mode: compiles Demon with -D DEBUG and links stdlib # WARNING: increases payload size and exposes debug console output sudo ./havoc server --profile ./profiles/havoc.yaotl --debug-dev # Available flags: # --profile Path to YAOTL profile (required) # -v / --verbose Enable verbose logging # -d / --debug Enable debug logging # --debug-dev Enable developer debug build of Demon # -h / --help Show help text ``` -------------------------------- ### Install Python 3.10 on Ubuntu 20.04/22.04 Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Enables Python 3.10 for Havoc client on Ubuntu. Ensure Python 3.10 is added to APT repositories before installation. ```bash sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.10 python3.10-dev ``` -------------------------------- ### Setup Python 3.10 on Debian 10/11 Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Configures the 'bookworm' repository for Python 3.10 on Debian. This is necessary for running the Havoc client. ```bash echo 'deb http://ftp.de.debian.org/debian bookworm main' >> /etc/apt/sources.list sudo apt update sudo apt install python3-dev python3.10-dev libpython3.10 libpython3.10-dev python3.10 ``` -------------------------------- ### Install Dependencies on MacOS Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Installs required software using Homebrew on MacOS, including CMake, Python 3.10, Qt5, and Spdlog. ```bash brew install --cask cmake brew install python@3.10 qt@5 spdlog golang brew link --overwrite qt@5 ``` -------------------------------- ### HCL JSON Alternative Syntax Example Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/intro.rst Shows the equivalent HCL configuration using its JSON-based alternative syntax. This is useful for programmatic generation of configuration files. ```json { "io_mode": "async", "service": { "http": { "web_proxy": { "listen_addr": "127.0.0.1:8080", "process": { "main": { "command": ["/usr/local/bin/awesome-app", "server"] }, "mgmt": { "command": ["/usr/local/bin/awesome-app", "mgmt"] }, } } } } } ``` -------------------------------- ### Start Havoc Teamserver Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Launches the Havoc Teamserver with verbosity and debugging enabled. Data is stored in the /Havoc/data/* directory. ```bash ./teamserver server --profile ./profiles/havoc.yaotl -v --debug ``` -------------------------------- ### Build Havoc Teamserver Natively Source: https://github.com/havocframework/havoc/blob/main/teamserver/README.md Compile the Havoc Teamserver binary locally. Ensure Go 1.18 is installed. The compiled binary will be available in the /bin folder. ```bash make ``` -------------------------------- ### Install Havoc Build Dependencies on Debian Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Installs essential packages required for building the Havoc framework on Debian-based systems. Ensure all listed dependencies are installed before proceeding with the build process. ```bash sudo apt install -y git build-essential apt-utils cmake libfontconfig1 libglu1-mesa-dev libgtest-dev libspdlog-dev libboost-all-dev libncurses5-dev libgdbm-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev mesa-common-dev qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5websockets5 libqt5websockets5-dev qtdeclarative5-dev golang-go qtbase5-dev libqt5websockets5-dev libspdlog-dev python3-dev libboost-all-dev mingw-w64 nasm ``` -------------------------------- ### Example of 'try' function usage Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/ext/tryfunc/README.md Demonstrates how the 'try' function returns a default value when an expression fails. ```hcl try(non_existent_variable, 2) # returns 2 ``` -------------------------------- ### Register Custom Agent with HavocService Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Example of how to instantiate a custom agent and register it with the HavocService. Ensure the endpoint and password match your teamserver configuration. ```python from havoc.service import HavocService from havoc.agent import * class MyCustomAgent(AgentType): # ... pass agent = MyCustomAgent() havoc_service = HavocService( endpoint="ws://0.0.0.0:40056/service-endpoint", password="service-password" ) havoc_service.register_agent(agent) ``` -------------------------------- ### Run Havoc Teamserver with Default Profile and Verbose Output Source: https://github.com/havocframework/havoc/blob/main/teamserver/README.md Start the teamserver using its default profile and enable verbose logging. This is a convenient option when a custom profile is not needed. ```bash ./teamserver server --default -v ``` -------------------------------- ### Walking Variables in Dynamic Blocks (Go) Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/ext/dynblock/README.md Provides a Go example of using 'WalkForEachVariables' to traverse dynamic blocks and identify referenced variables. This is useful for applications that dynamically generate evaluation contexts by analyzing variable references. ```go func walkVariables(node dynblock.WalkVariablesNode, schema *hcl.BodySchema) []hcl.Traversal { vars, children := node.Visit(schema) for _, child := range children { var childSchema *hcl.BodySchema switch child.BlockTypeName { case "a": childSchema = &hcl.BodySchema{ Blocks: []hcl.BlockHeaderSchema{ { Type: "b", LabelNames: []string{"key"}, }, }, } case "b": childSchema = &hcl.BodySchema{ Attributes: []hcl.AttributeSchema{ { Name: "val", Required: true, }, }, } default: // Should never happen, because the above cases should be exhaustive // for the application's configuration format. panic(fmt.Errorf("can't find schema for unknown block type %q", child.BlockTypeName)) } vars = append(vars, testWalkAndAccumVars(child.Node, childSchema)...) } return vars } ``` -------------------------------- ### Run HCL Spec Suite Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/specsuite/README.md Execute the HCL spec suite by providing the directory of test definitions and the path to the `hcldec` executable. This example assumes you are in the root of the repository. ```bash go install ./cmd/hcldec hclspecsuite ./specsuite/tests $GOPATH/bin/hcldec ``` -------------------------------- ### HCL Argument Expression Example Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/intro.rst Illustrates using an environment variable within an HCL argument expression. This allows dynamic configuration values. ```hcl listen_addr = env.LISTEN_ADDR ``` -------------------------------- ### Install Python 3.10 Development Files on Ubuntu Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Install Python 3.10 and its development files on Ubuntu systems to resolve build errors related to Python.h. This may require adding the deadsnakes PPA for newer Python versions. ```bash sudo apt install build-essential sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.10 python3.10-dev ``` -------------------------------- ### Example usage of `with` function in HCL Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/ext/customdecode/README.md Demonstrates how to call the `with` function in HCL syntax, providing local variables and an expression to evaluate. Use with care as it makes expressions context-sensitive. ```hcl foo = with({name = "Cory"}, "${greeting}, ${name}!") ``` -------------------------------- ### Run Havoc Teamserver with Profile and Verbose Output Source: https://github.com/havocframework/havoc/blob/main/teamserver/README.md Run the teamserver with a specified profile and enable verbose logging. This is a common way to start the teamserver for detailed operation monitoring. ```bash ./teamserver server --profile profiles/havoc.yaotl -v ``` -------------------------------- ### Decode with Evaluation Context Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_decoding_hcldec.rst This example shows how to provide an evaluation context to hcldec.Decode, allowing expressions within the configuration to reference variables like the current process ID. ```go ctx := &hcl.EvalContext{ Variables: map[string]cty.Value{ "pid": cty.NumberIntVal(int64(os.Getpid())), }, } val, moreDiags := hcldec.Decode(f.Body, spec, ctx) diags = append(diags, moreDiags...) ``` -------------------------------- ### Run BOF and Get Output in Python Source: https://github.com/havocframework/havoc/wiki/BOF-support Execute an object file and capture its output via a Python callback function. Ensure the 'Demon' class and necessary imports are available. ```python def my_callback(demonID, worked, output): print('hi there! I am the python callback of the "locale" BOF') print(f'demonID: {demonID}') print(f'did the BOF run ok?: {worked}') if worked: print('here you have the output :) print(output) print('bye!') def locale( demonID, *param ): TaskID : str = None demon : Demon = None demon = Demon( demonID ) return demon.InlineExecuteGetOutput( my_callback, "go", "ObjectFiles/locale.x64.o", b'' ) ``` -------------------------------- ### Terraform Resource Block Example Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/language_design.rst Demonstrates a complex HCL block structure using the Terraform resource block for an AWS instance, including nested blocks and object arguments. ```hcl resource "aws_instance" "example" { ami = "ami-abc123" instance_type = "t2.micro" tags = { Name = "example instance" } ebs_block_device { device_name = "hda1" volume_size = 8 volume_type = "standard" } } ``` -------------------------------- ### HCL Configuration for Interdependent Blocks Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_patterns.rst Example HCL configuration demonstrating interdependent blocks like variables, locals, and resources. This illustrates how values from one block can be used in others, a common pattern in systems like Terraform. ```hcl variable "network_numbers" { type = list(number) } variable "base_network_addr" { type = string default = "10.0.0.0/8" } locals { network_blocks = { for x in var.number: x => cidrsubnet(var.base_network_addr, 8, x) } } resource "cloud_subnet" "example" { for_each = local.network_blocks cidr_block = each.value } output "subnet_ids" { value = cloud_subnet.example[*].id } ``` -------------------------------- ### Define a service block with processes Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/language_design.rst Example of a top-level 'service' block used to configure an HTTP web proxy, including nested 'process' blocks for application components. This structure can be exposed to expressions. ```hcl service "http" "web_proxy" { listen_addr = "127.0.0.1:8080" process "main" { command = ["/usr/local/bin/awesome-app", "server"] } process "mgmt" { command = ["/usr/local/bin/awesome-app", "mgmt"] } } ``` -------------------------------- ### Execute .NET Assemblies Inline Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD List installed .NET versions or execute a .NET assembly directly within the current process. Be aware that inline execution creates a CLR instance and patches AMSI, which may increase detection risks. ```bash dotnet list-versions ``` ```bash dotnet inline-execute [path-to-assembly] [args] ``` -------------------------------- ### Build and Run Havoc Client Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Compiles the Havoc client binary and then runs it. Ensure you are in the Havoc root directory before executing. ```bash # Build the client Binary (From Havoc Root Directory) make client-build # Run the client ./havoc client ``` -------------------------------- ### Basic Teamserver Help Source: https://github.com/havocframework/havoc/blob/main/teamserver/README.md Display help information for the teamserver binary. This is useful for understanding available commands and options. ```bash ./teamserver -h ``` -------------------------------- ### HCL Variable Type Declaration Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/ext/typeexpr/README.md Example of declaring a variable with a list of strings type in HCL native syntax. ```hcl variable "example" { type = list(string) } ``` -------------------------------- ### Gradual Evaluation with Unknown Values in Go Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_patterns.rst Demonstrates setting up an evaluation context with unknown values for gradual evaluation. Unknown values propagate through expressions, allowing for type checking before all data is available. ```go ctx := &hcl.EvalContext{ Variables: map[string]cty.Value{ "name": cty.UnknownVal(cty.String), "age": cty.UnknownVal(cty.Number), }, } val, moreDiags := expr.Value(ctx) diags = append(diags, moreDiags...) ``` -------------------------------- ### Reference Basic Variables in HCL Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_expression_eval.rst An example of an HCL expression that uses the 'name' and 'age' variables defined in the evaluation context. ```hcl message = "${name} is ${age} ${age == 1 ? "year" : "years"} old!" ``` -------------------------------- ### Create Linux Ramdisk Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/hclsyntax/fuzz/README.md Use these commands to create a ramdisk on Linux for go-fuzz efficiency. Ensure the RAMDISK environment variable is set. ```bash $ mkdir /mnt/ramdisk $ mount -t tmpfs -o size=1024M tmpfs /mnt/ramdisk $ export RAMDISK=/mnt/ramdisk ``` -------------------------------- ### Run Havoc Teamserver Natively Source: https://github.com/havocframework/havoc/blob/main/teamserver/README.md Execute the compiled Havoc Teamserver binary. Use the --profile and --verbose flags for specific configurations or the --default flag for default settings. ```bash sudo ./teamserver server --profile profiles/havoc.yaotl --verbose ``` ```bash sudo ./teamserver --default --verbose ``` -------------------------------- ### Parse HCL File with hclparse Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_parsing.rst Use `hclparse.NewParser()` to create a parser and then `ParseHCLFile` to load and parse a configuration file. The result is an `hcl.File` object and `hcl.Diagnostics` for errors or warnings. ```go parser := hclparse.NewParser() f, diags := parser.ParseHCLFile("server.conf") ``` -------------------------------- ### Example JSON Structure Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_decoding_hcldec.rst This JSON structure represents the expected shape of the decoded data based on the hcldec specification defined previously. It illustrates nested objects and arrays. ```json { "io_mode": "async", "services": { "http": { "web_proxy": { "listen_addr": "127.0.0.1:8080", "processes": { "main": { "command": ["/usr/local/bin/awesome-app", "server"] }, "mgmt": { "command": ["/usr/local/bin/awesome-app", "mgmt"] } } } } } } ``` -------------------------------- ### Manage Processes with `proc` Source: https://context7.com/havocframework/havoc/llms.txt Enumerate, create, kill, and inspect processes on the target host. Supports listing, killing by PID, creating processes in suspended or normal states, listing modules, searching by name, and inspecting memory pages. ```text # List all running processes proc list # Kill a specific process by PID proc kill 4812 # Start notepad.exe in suspended state proc create suspended C:\Windows\System32\notepad.exe # Start cmd.exe normally with arguments proc create normal C:\Windows\System32\cmd.exe /c whoami # List loaded modules for a PID proc module 4812 # Search for a process by name proc grep svchost.exe # Output: Name=svchost.exe PID=4812 PPID=664 User=SYSTEM Arch=x64 # Enumerate process memory pages with PAGE_EXECUTE_READ_WRITE protection proc memory 4812 0x40 ``` -------------------------------- ### Create macOS Ramdisk Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/hclsyntax/fuzz/README.md Use these commands to create a ramdisk on macOS for go-fuzz efficiency. Ensure the RAMDISK environment variable is set. ```bash $ SIZE_IN_MB=1024 $ DEVICE=`hdiutil attach -nobrowse -nomount ram://$(($SIZE_IN_MB*2048))` $ diskutil erasevolume HFS+ RamDisk $DEVICE $ export RAMDISK=/Volumes/RamDisk ``` -------------------------------- ### Define Basic Variables in EvalContext Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_expression_eval.rst Sets up an evaluation context with simple string and number variables. These can be referenced directly in HCL expressions. ```go ctx := &hcl.EvalContext{ Variables: map[string]cty.Value{ "name": cty.StringVal("Ermintrude"), "age": cty.NumberIntVal(32), }, } ``` -------------------------------- ### Build Havoc Client Docker Image Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Builds a Docker image tagged 'havoc-client' using the provided Dockerfile. ```docker sudo docker build -t havoc-client -f Client-Dockerfile . ``` -------------------------------- ### Expanding Dynamic Blocks in Go Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/ext/dynblock/README.md Illustrates how to use the 'Expand' function to process HCL bodies containing dynamic blocks. It requires passing an evaluation context for expressions within the dynamic blocks. ```go func Expand(body hcl.Body, ctx *hcl.EvalContext) (hcl.Body, diag.Diagnostics) { // ... implementation details ... } ``` -------------------------------- ### Accumulating Diagnostics in Go Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_diagnostics.rst This pattern shows how to collect diagnostics from multiple sources within a Go function. Always append diagnostics and check for errors to decide whether to return early. ```go func returningDiagnosticsExample() hcl.Diagnostics { var diags hcl.Diagnostics // ... // Call a function that may itself produce diagnostics. f, moreDiags := parser.LoadHCLFile("example.conf") // always append, in case warnings are present diags = append(diags, moreDiags...) if diags.HasErrors() { // If we can't safely continue in the presence of errors here, // we can optionally return early. return diags } // ... return diags } ``` -------------------------------- ### Exporting 'try' and 'can' functions in HCL EvalContext Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/ext/tryfunc/README.md Shows how to make the 'try' and 'can' functions available in an hcl.EvalContext for use in HCL expressions. ```go ctx := &hcl.EvalContext{ Functions: map[string]function.Function{ "try": tryfunc.TryFunc, "can": tryfunc.CanFunc, }, } ``` -------------------------------- ### Configure HTTP/HTTPS Listener Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Set up an HTTP/HTTPS listener with various parameters such as name, kill date, working hours, hosts, ports, method, and URIs. The response headers can also be customized. ```hcl Listeners { Http { Name = "HTTPS Listener" KillDate = "2006-01-02 15:04:05" WorkingHours = "8:00-17:00" Hosts = ["10.0.0.10"] PortBind = 443 PortConn = 443 Method = "POST" Secure = true UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36" Uris = [ "/funny_cat.gif", "/index.php", "/test.txt", "/helloworld.js" ] Headers = [ "X-Havoc: true", "X-Havoc-Agent: Demon", ] Response { Headers = [ "Content-type: text/plain", "X-IsHavocFramework: true", ] } } } ``` -------------------------------- ### Define Functions in EvalContext Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_expression_eval.rst Configures an evaluation context to include standard library functions for string manipulation and comparisons. Requires importing the 'stdlib' package from 'go-cty'. ```go ctx := &hcl.EvalContext{ Variables: map[string]cty.Value{ "name": cty.StringVal("Ermintrude"), }, Functions: map[string]function.Function{ "upper": stdlib.UpperFunc, "lower": stdlib.LowerFunc, "min": stdlib.MinFunc, "max": stdlib.MaxFunc, "strlen": stdlib.StrlenFunc, "substr": stdlib.SubstrFunc, }, } ``` -------------------------------- ### Build Havoc Teamserver with Docker Source: https://github.com/havocframework/havoc/blob/main/teamserver/README.md Build the Havoc Teamserver Docker image. This command creates an image tagged as 'havoc-teamserver'. ```bash sudo docker build -t havoc-teamserver -f Teamserver-Dockerfile . ``` -------------------------------- ### Define Custom Command with Havoc API Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Demonstrates defining a custom command by extending the Command class. This includes setting command properties and implementing the job generation logic. ```python class CommandShell(Command): CommandId = COMMAND_SHELL Name = "shell" Description = "executes commands using cmd.exe" Help = "" NeedAdmin = False Params = [ CommandParam( name="commands", is_file_path=False, is_optional=False ) ] Mitr = [] def job_generate( self, arguments: dict ) -> bytes: Task = Packer() Task.add_int( self.CommandId ) Task.add_data( "c:\\windows\\system32\\cmd.exe /c " + arguments[ 'commands' ] ) return Task.buffer ``` -------------------------------- ### Using the `convert` Function for Type Conversion Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/ext/typeexpr/README.md Demonstrates how to use the `convert` function to convert a string representation of a boolean to an actual boolean type. The target type constraint must be provided statically. ```hcl foo = convert("true", bool) ``` -------------------------------- ### hclparse.Parser Usage Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_parsing.rst Demonstrates the basic usage of the hclparse.Parser to parse an HCL file. It shows how to create a parser instance and call ParseHCLFile, explaining the returned file object and diagnostics. ```APIDOC ## Parsing HCL Input The main entry point into HCL parsing is :go:pkg:`hclparse`, which provides :go:type:`hclparse.Parser`. ### Example Usage ```go parser := hclparse.NewParser() f, diags := parser.ParseHCLFile("server.conf") ``` - ``f``: A pointer to an :go:type:`hcl.File`, representing the parsed HCL content. - ``diags``: An :go:type:`hcl.Diagnostics` object containing any errors or warnings encountered during parsing. ``` -------------------------------- ### List All Git Branches Source: https://github.com/havocframework/havoc/blob/main/CONTRIBUTING.MD Verify that your new branch has been created successfully by listing all available local and remote branches. ```git git branch -a ``` -------------------------------- ### Manage Tokens with `token` Source: https://context7.com/havocframework/havoc/llms.txt Steal, store, and impersonate Windows access tokens. All stolen tokens are preserved in a per-session token vault. Use `getuid` to print the current user identity. ```text # Print current user identity token getuid # Output: CONTOSO\jdoe (High Integrity) ``` -------------------------------- ### HCL Block vs. Object Constructor Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/language_design.rst Illustrates the syntactic similarity and structural difference between an HCL block and an argument with an object constructor expression. ```hcl block { foo = bar } # argument with object constructor expression argument = { foo = bar } ``` -------------------------------- ### Run Client Docker Container Source: https://github.com/havocframework/havoc/blob/main/teamserver/README.md Launch the Havoc client container, mapping necessary ports for teamserver communication. Ensure port mappings match your environment. Access the teamserver at localhost:40056. ```bash sudo docker run -p40056:40056 -p 443:443 -it -d -v havoc-c2-data:/data jenkins-havoc-client ``` -------------------------------- ### Manage Tokens with Demon Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Use these commands to manage tokens, including stealing, impersonating, creating, and removing them from the vault. Ensure you understand the implications of privilege modification. ```bash token getuid ``` ```bash token list ``` ```bash token find-tokens ``` ```bash token steal [pid] (handle) ``` ```bash token impersonate [id] ``` ```bash token make [domain] [username] [password] ``` ```bash token privs-get ``` ```bash token privs-list ``` ```bash token revert ``` ```bash token remove [id] ``` ```bash token clear ``` -------------------------------- ### Build Jenkins Docker Image for Havoc Teamserver Source: https://github.com/havocframework/havoc/blob/main/teamserver/README.md Build a Docker image using a pre-configured Jenkins Dockerfile. This image is intended for CI/CD pipelines. ```bash sudo docker build -t jenkins-havoc-teamserver -f JT-Dockerfile . ``` -------------------------------- ### Request Agent Metadata with `checkin` Source: https://context7.com/havocframework/havoc/llms.txt Forces the Demon agent to send a full check-in packet. This includes host, process, and configuration metadata. The output provides detailed information about the agent's environment. ```text # In the Havoc client interact window: checkin # Expected output includes: # [Demon Metadata] # AES Key / IV, Sleep Delay, Magic Value, First/Last CallIn # [Host Info] # Hostname: DESKTOP-ABC123 Username: CONTOSO\jdoe Domain: CONTOSO Internal IP: 192.168.1.50 # [Process Info] # Name: svchost.exe Arch: x64 PID: 4812 Path: C:\Windows\System32\svchost.exe Elevated: false # [OS] # Version: Windows 10 Build: 19045 Arch: x64/AMD64 ``` -------------------------------- ### Create Docker Volume for Client Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Creates a Docker volume named 'havoc-c2-client' for persistent storage of client data. ```docker sudo docker volume create havoc-c2-client ``` -------------------------------- ### Constructing and Unpacking cty Type Values Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/ext/typeexpr/README.md Demonstrates how to create a cty type capsule value and extract the cty.Type from it using the typeexpr package. ```go tyVal := typeexpr.TypeConstraintVal(cty.String) // We can unpack the type from a value using TypeConstraintFromVal ty := typeExpr.TypeConstraintFromVal(tyVal) ``` -------------------------------- ### Clone Havoc Repository Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Clones the official Havoc Framework repository from GitHub to your local machine. ```bash git clone https://github.com/HavocFramework/Havoc.git ``` -------------------------------- ### Build Client Docker Image Source: https://github.com/havocframework/havoc/blob/main/teamserver/README.md Build the Docker image for the Havoc client. This image is used to run the teamserver completely within a container. ```bash sudo docker build -f Client-Dockerfile . ``` -------------------------------- ### Static Reference in HCL for Resource Dependencies Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_patterns.rst Illustrates how HCL uses static references for arguments like 'depends_on' to build dependency graphs, rather than evaluating them to a value. This is crucial for understanding resource relationships. ```hcl resource "cloud_network" "example" { # ... } resource "cloud_subnet" "example" { cidr_block = "10.1.2.0/24" depends_on = [ cloud_network.example, ] } ``` -------------------------------- ### Build Jenkins Dockerfile for Client Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Builds a Docker image using a Jenkins-specific Dockerfile. Note: This command does not tag the image. ```docker sudo docker build -f JC-Dockerfile . ``` -------------------------------- ### HCL Locals Block Syntax Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/language_design.rst Demonstrates the use of the `locals` block for defining arbitrary, top-level objects with free-form keys. This provides an ergonomic syntax for simple, single-expression objects. ```hcl locals { instance_type = "t2.micro" instance_id = aws_instance.example.id } ``` -------------------------------- ### Rendering Diagnostics with HCL Text Writer Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/guide/go_diagnostics.rst Use `hcl.NewDiagnosticTextWriter` to create a default diagnostic renderer for command-line tools. This writer can output to a specified writer, include source code snippets, and support colored output. ```go wr := hcl.NewDiagnosticTextWriter( os.Stdout, // writer to send messages to parser.Files(), // the parser's file cache, for source snippets 78, // wrapping width true, // generate colored/highlighted output ) wr.WriteDiagnostics(diags) ``` -------------------------------- ### Safe deep data structure traversal with 'try' Source: https://github.com/havocframework/havoc/blob/main/teamserver/pkg/profile/yaotl/ext/tryfunc/README.md Illustrates using 'try' to access nested data structures, providing a default value if any part of the path is missing. ```hcl result = try(foo.deep[0].lots.of["traversals"], null) ``` -------------------------------- ### Configure Teamserver Host and Port Source: https://github.com/havocframework/havoc/blob/main/WIKI.MD Sets the bind address and port for the Teamserver to accept client connections. This configuration is part of the yaotl profile. ```hcl Teamserver { Host = "0.0.0.0" Port = 40056 } ```